FAQBrowser MonitoringCan I load Atatus async?

We recommend loading Atatus synchronously before any of your other scripts to maximize compatibility with older browsers and report as many of your errors as possible.

If async loading of all of your javascript is important to you, you can do it as follows.

<script>
  !function(window, document) {

      window._atatusConfig = {
          apikey: 'YOUR API KEY',
          // Other options if needed
      };

      function _asyncAtatus(callback) {
          var script = document.createElement("script");
          script.type = "text/javascript";
          script.async = true;
          script.src = "https://dmc1acwvwny3.cloudfront.net/atatus.js";
          var node = document.getElementsByTagName("script")[0];
          if (script.addEventListener) {
            script.addEventListener('load', function (e) {
                callback(null, e);
            }, false);
          }
          node.parentNode.insertBefore(script, node);
      }

      _asyncAtatus(function() {
          // Any atatus related calls.
          if (window.atatus) {
              // window.atatus.setUser('unique_user_id', 'emailaddress@company.com', 'Full Name');
          }
      });

  }(window, document);
</script>