The `launchdarkly-js-client-sdk` package provides client-side feature flag management for JavaScript applications running in web browsers. It allows developers to control features remotely without redeploying code, enabling practices like A/B testing, gradual rollouts, and kill switches. This specific package is currently at version 3.9.1 but is officially deprecated. All future development and releases are now happening under the `@launchdarkly/js-client-sdk` monorepo package. It leverages the 'Client-side ID' for authentication and requires flags to be explicitly made available to client-side SDKs. Release cadence was previously frequent for this package, but it is now in maintenance mode, with new features directed to the new package. Its primary differentiator is robust feature flag management with detailed event tracking and a strong focus on enterprise features, often used in conjunction with React through the `react-client-sdk` addon.
npm install launchdarkly-js-client-sdkVerified import paths — ran on the pinned version, not inferred.
Initializes the LaunchDarkly client for a given user, evaluates a boolean feature flag, and tracks a custom event, logging results to the console.
Migrate your project to use the `@launchdarkly/js-client-sdk` package. Refer to the official LaunchDarkly documentation and migration guides for the new package.
Verify that you are using the correct 'Client-side ID' found in your LaunchDarkly project's environment settings. It typically starts with '5...'.
Check the settings for any feature flags you intend to use with this SDK and ensure the client-side availability option is enabled.
Include appropriate polyfills (e.g., `core-js`, `whatwg-fetch`) in your application bundle if you need to support older browsers. Consult the LaunchDarkly documentation on 'JS SDK requirements and polyfills'.
Consider adding an optional timeout parameter to `waitForInitialization` (e.g., `ldClient.waitForInitialization(5000)`) to ensure that the promise eventually resolves or rejects, preventing indefinite blocking.
Double-check the provided Client-side ID against your LaunchDarkly project settings. Ensure your client device has active internet access and is not being blocked by a firewall or proxy from reaching LaunchDarkly endpoints.
Add a `Promise` polyfill (e.g., from `core-js` or `es6-promise`) to your application bundle to ensure compatibility with older browsers.
Ensure you call `ldClient.variation` only after the `ready` event fires or `waitForInitialization()` resolves, indicating the client is ready to provide flag values. Handle potential initialization failures gracefully.
No dependency data recorded yet.