amplitude / experiment-js-client

Amplitude Experiment client-side SDK for JavaScript
MIT License
8 stars 7 forks source link

chore: update experiment script to support async #123

Closed bgiori closed 3 months ago

bgiori commented 3 months ago

Anti-flicker script is:

  <script>
    // Set a timeout in milliseconds for the anti-flicker.
    var timeout = 1000;
    var id = "amp-exp-css";
    if (!document.getElementById(id)) {
      var s = document.createElement("style");
      s.id = id;
      s.innerText = "* { visibility: hidden !important; background-image: none !important; }";
      document.head.appendChild(s);
      window.setTimeout(function () {s.remove()}, timeout);
    }
  </script>