fg-loadcss
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "fg-loadcss", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A function for loading CSS asynchronously", | ||
@@ -5,0 +5,0 @@ "main": "src/loadCSS.js", |
@@ -11,2 +11,5 @@ # loadCSS | ||
* Latest release: https://github.com/filamentgroup/loadCSS/releases | ||
* NPM: https://www.npmjs.com/package/fg-loadcss | ||
## Basic Usage | ||
@@ -35,3 +38,3 @@ | ||
With that markup in the `head` of your page, include the [loadCSS script](https://github.com/filamentgroup/loadCSS/blob/master/src/onloadCSS.js), as well as the [loadCSS rel=preload polyfill script](https://github.com/filamentgroup/loadCSS/blob/master/src/cssrelpreload.js) in your page (inline to run right away, or in an external file if the CSS is low-priority). | ||
With that markup in the `head` of your page, include the [loadCSS script](https://github.com/filamentgroup/loadCSS/blob/master/src/loadCSS.js), as well as the [loadCSS rel=preload polyfill script](https://github.com/filamentgroup/loadCSS/blob/master/src/cssrelpreload.js) in your page (inline to run right away, or in an external file if the CSS is low-priority). | ||
@@ -38,0 +41,0 @@ No further configuration is needed, as these scripts will automatically detect if the browsers supports `rel=preload`, and if it does not, they will find CSS files referenced in the DOM and preload them using loadCSS. In browsers that natively support `rel=preload`, these scripts will do nothing, allowing the browser to load and apply the asynchronous CSS (note the `onload` attribute above, which is there to set the `link`'s `rel` attribute to stylesheet once it finishes loading in browsers that support `rel=preload`). |
@@ -34,2 +34,3 @@ /*! CSS rel=preload polyfill. Depends on loadCSS function. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT */ | ||
w.addEventListener( "load", function(){ | ||
rp.poly(); | ||
w.clearInterval( run ); | ||
@@ -36,0 +37,0 @@ } ); |
@@ -43,3 +43,3 @@ /*! loadCSS: load a CSS file asynchronously. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT */ | ||
}); | ||
// A method (exposed on return object for external use) that mimics onload by polling until document.styleSheets until it includes the new sheet. | ||
// A method (exposed on return object for external use) that mimics onload by polling document.styleSheets until it includes the new sheet. | ||
var onloadcssdefined = function( cb ){ | ||
@@ -46,0 +46,0 @@ var resolvedHref = ss.href; |
Sorry, the diff of this file is not supported yet
98847
2351
178