toggly
  • What is toggly?
  • 🚀Getting started
    • Creating your first project
    • Using our Feature Flag Demo
    • Inviting Your Team
    • API Documentation
  • 🔘Feature Flags
    • Feature Flags in C# / .NET
      • Views
      • Controllers & Actions
      • Dependency Injection
      • Routing
      • IFeatureManagerSnapshot
      • Persistent Flags Across Requests
      • Disabled Action Handling
      • State Change Handlers
      • Custom Context
      • Snapshot Providers
        • RavenDB
        • Entity Framework
      • Debugging Endpoint
      • Serving Front-end Flags
      • Undefined Features In Development
      • Deployments and Version
    • Feature Flags in Vue.js
      • Feature Component
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in JavaScript
      • Directly Checking a Flag
      • Definition Refresh
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in Flutter
      • Feature Widget
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in HTML/CSS
  • 📈Metrics
    • Metrics in C# / .NET
      • Feature Usage
      • Business Metrics
      • Performance Metrics
  • 👩‍💻Use Cases
    • For Engineers
      • Develop continuously, turn on when ready
    • For Product Managers
      • Measure Feature Impact
    • For Agile Teams
      • Faster QA Cycles
      • Streamline Your Releases
Powered by GitBook
On this page
  • Installation
  • Basic Usage

Was this helpful?

  1. Feature Flags

Feature Flags in JavaScript

PreviousFlag DefaultsNextDirectly Checking a Flag

Last updated 2 years ago

Was this helpful?

Installation

Simply embed our latest bundle from the following CDN.

<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.

$ 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.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.

🔘
Toggly application page
Directly Checking a Flag
Definition Refresh