Async SDK loading

In cases where you do not want our SDK to delay your page load sequence, you may embed it asynchronously once your page DOM has loaded.

Please follow the code example below to invoke our SDK on the DOM ready (DOMContentLoaded) browser event.

<script>
  window.QLAsync = function(QL){
    // ------ IMPORTANT -----------
    // --
    // ADD actual SDK initializing and invocation here
    // depending on the target page and embed system
    // --
    // ------ IMPORTANT -----------
  }
  
  function embedQLSDK () {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = '//d3jdlwnuo8nsnr.cloudfront.net/sdk/v3.0/ql.js';
    var n = document.getElementsByTagName('script')[0];
    n.parentNode.insertBefore(s, n);
  }
  
  // if you're using jQuery, please replace this line
  // with $(document).ready(embedQLSDK);
  document.addEventListener('DOMContentLoaded', embedQLSDK);
</script>

The first function in the above <script> tag is the QLAsync function - it is left empty intentionally, and you should add the relevant code that suits your integration style and target page.

The second function in the above <script> tag is the embedQLSDK function - it will programmatically add our SDK script to the page when it is called.

The final line in the above <script> tag listens to the DOMContentLoaded browser event, and then calls the embedQLSDK function when the event is triggered.

Adding the SDK's script to the page only when the DOM is ready means that the SDK load time and subsequent request to our servers should not affect your overall page load time.