Lazy loading

By default Fanplayr uses asynchronous loading. Our embed code does not call Fanplayr directly, but instead writes a new JavaScript node to the DOM. This means it will stop passing of your page, and will be loaded when the browser has spare time to do so. This will always be after the DOMContentLoaded event, but may also be before the page’s OnLoad event.

If Fanplayr is loaded before your OnLoad event, this event may then not fire until Fanplayr has finished loading. This does not increase the time it takes until your page is able to be interacted with by your users, but some analytics software i.e. Google Analytics may say your page load times have increased.

To force Fanplayr to load later, we simply wrap our embed code (this should only be done for user tracking) in JavaScript that will only fire after the OnLoad event. For example:

(function(d, w, s) {
  var f = function(){
    // Embed code goes here
  };

  if (w.addEventListener) {
    w.addEventListener('load', f, false);
  } else if (w.attachEvent) {
    w.attachEvent('onload', f);
  }
})(document, window, 'script');