Sha256: 514c504b1c472c4174a65f89fb5ec7f5cef9fb08193042949fd6f0d8b885ae5f

Contents?: true

Size: 1.17 KB

Versions: 33

Compression:

Stored size: 1.17 KB

Contents

/*! CSS rel=preload polyfill. Depends on loadCSS function. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT  */
(function( w ){
  // rel=preload support test
  if( !w.loadCSS ){
    return;
  }
  var rp = loadCSS.relpreload = {};
  rp.support = function(){
    try {
      return w.document.createElement( "link" ).relList.supports( "preload" );
    } catch (e) {
      return false;
    }
  };

  // loop preload links and fetch using loadCSS
  rp.poly = function(){
    var links = w.document.getElementsByTagName( "link" );
    for( var i = 0; i < links.length; i++ ){
      var link = links[ i ];
      if( link.rel === "preload" && link.getAttribute( "as" ) === "style" ){
        w.loadCSS( link.href, link );
        link.rel = null;
      }
    }
  };

  // if link[rel=preload] is not supported, we must fetch the CSS manually using loadCSS
  if( !rp.support() ){
    rp.poly();
    var run = w.setInterval( rp.poly, 300 );
    if( w.addEventListener ){
      w.addEventListener( "load", function(){
        w.clearInterval( run );
      } );
    }
    if( w.attachEvent ){
      w.attachEvent( "onload", function(){
        w.clearInterval( run );
      } )
    }
  }
}( this ));

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
izi_lightup-1.0.31 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.29 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.28 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.27 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.26 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.25 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.24 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.23 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.22 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.21 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.20 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.19 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.18 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.17 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.16 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.15 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.14 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.13 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.12 vendor/assets/javascripts/cssrelpreload.js
izi_lightup-1.0.11 vendor/assets/javascripts/cssrelpreload.js