# Feature Flags in JavaScript

### Installation

Simply embed our latest bundle from the following CDN.

```html
<script src="https://cdn.jsdelivr.net/npm/@ops-ai/feature-flags-toggly@1.0.2/dist/feature-flags-toggly.bundle.js"></script>
```

Alternatively, you can use NPM to manually build the bundled \*.js file.

```sh
$ npm install @ops-ai/feature-flags-toggly
$ cd node_modules/@ops-ai/feature-flags-toggly && npm run build
```

And then grab the generated bundled file from the ./dist directory.

### Basic Usage

Initialize Toggly by running the Toggly.init method and by providing your App Key from your [Toggly application page](https://app.toggly.io)

```javascript
Toggly.init({
  appKey: '<YOUR_APP_KEY>',
  environment: '<YOUR_APP_ENVIRONMENT>'
})
  .then(function () {
    // Now you can check if a feature (or more) is Enabled/Disabled
    
    if (Toggly.isFeatureOn('SignUpButton')) {
      // SignUpButton is ON
    }

    if (Toggly.isFeatureOff('DemoScreenshot')) {
      // DemoScreenshot is OFF
    }
});
```

You can also check multiple feature keys and make use of the *requirement* (`FeatureRequirement.all`, `FeatureRequirement.any`) and `negate` (bool) options.

{% content-ref url="feature-flags-in-javascript/directly-checking-a-flag" %}
[directly-checking-a-flag](https://docs.toggly.io/feature-flags/feature-flags-in-javascript/directly-checking-a-flag)
{% endcontent-ref %}

{% content-ref url="feature-flags-in-javascript/definition-refresh" %}
[definition-refresh](https://docs.toggly.io/feature-flags/feature-flags-in-javascript/definition-refresh)
{% endcontent-ref %}
