Toggle jQuery Code With Ease

Reduce risk, iterate quicker, and get more control with LaunchDarkly
jQuery toggle management. Try it out free with a 30-day trial.

Try It Free
Feature flag lifecycle management
Reduce
technical debt
Manage feature flags at enterprise scale across multiple dev environments with flag statuses, audit logging, and custom roles
Feature toggle user and performance feedback
Release faster
with less risk
Reduce risk to customer impact by releasing to limited user segments and testing your infrastructure behind feature flags
Feature flags kill switch and feature toggles
Central platform
for controlling features
LaunchDarkly’s user interface allows non-technical users to control user targeting and implement feature flagging best practices

Toggle jQuery with LaunchDarkly

Let's create a JavaScript feature toggle for a "One Click Checkout"

1.Add the SDK snippet to your site pages.

Check out the reference documentation.

               
       <head>
          <script src="https://app.launchdarkly.com/snippet/ldclient.min.js"></script>
       </head>
                
              

2.Set the user context for the page.

First, create a user.  You can pass us any data about users for targeting and segmentation.

               
            var user = {
              "key": "aa0ceb",
              "firstName": "Ernestina",
              "lastName": "Evans",
              "email": "ernestina@example.com",
              "custom": {
                "groups": ["Google", "Microsoft"]
              }
            };
            var ldclient = LDClient.initialize('YOUR_CLIENT_SIDE_ID_HERE', user);
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

Call variation and see whether the flag is on for that user.

               
            var showFeature = ldclient.variation("one_click_checkout", false);
            if (showFeature) {
              // Show "One Click Checkout" feature
            } else {
              // the code to run if the feature is off
            }
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.

Testimonials
  • LaunchDarkly Testimonial
    I believe that feature flags are a critical piece of modern development, and LaunchDarkly brings this part of continuous delivery to the masses.
    - Rob Zuber, CTO, CircleCI
    LaunchDarkly Testimonial
    LaunchDarkly has been easy to on-board and integrate into our existing development cycle, which has helped us move faster with less risk.
    - Lawrence, VP Engineering, Ten-X

Try LaunchDarkly free for 30 days.

Continuously deliver and deploy software to your users in a faster, more reliable way. Get started today with a 30 day free trial.