File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed
vendor/assets/javascripts Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ The loadCSS and onloadCSS files will be added to the asset pipeline and availabl
1818
1919``` js
2020// = require loadCSS
21+ // = require cssrelpreload
2122// = require onloadCSS
2223```
2324
Original file line number Diff line number Diff line change 11module LoadCSS
22 module Rails
3- VERSION = '1.2.0 '
4- LOADCSS_VERSION = '1.2.0 '
3+ VERSION = '1.2.1 '
4+ LOADCSS_VERSION = '1.2.1 '
55 end
66end
Original file line number Diff line number Diff line change 1+ /*! CSS rel=preload polyfill. Depends on loadCSS function. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT */
2+ ( function ( w ) {
3+ // rel=preload support test
4+ if ( ! w . loadCSS ) {
5+ return ;
6+ }
7+ var rp = loadCSS . relpreload = { } ;
8+ rp . support = function ( ) {
9+ try {
10+ return w . document . createElement ( "link" ) . relList . supports ( "preload" ) ;
11+ } catch ( e ) {
12+ return false ;
13+ }
14+ } ;
15+
16+ // loop preload links and fetch using loadCSS
17+ rp . poly = function ( ) {
18+ var links = w . document . getElementsByTagName ( "link" ) ;
19+ for ( var i = 0 ; i < links . length ; i ++ ) {
20+ var link = links [ i ] ;
21+ if ( link . rel === "preload" && link . getAttribute ( "as" ) === "style" ) {
22+ w . loadCSS ( link . href , link ) ;
23+ link . rel = null ;
24+ }
25+ }
26+ } ;
27+
28+ // if link[rel=preload] is not supported, we must fetch the CSS manually using loadCSS
29+ if ( ! rp . support ( ) ) {
30+ rp . poly ( ) ;
31+ var run = w . setInterval ( rp . poly , 300 ) ;
32+ if ( w . addEventListener ) {
33+ w . addEventListener ( "load" , function ( ) {
34+ w . clearInterval ( run ) ;
35+ } ) ;
36+ }
37+ if ( w . attachEvent ) {
38+ w . attachEvent ( "onload" , function ( ) {
39+ w . clearInterval ( run ) ;
40+ } )
41+ }
42+ }
43+ } ( this ) ) ;
You can’t perform that action at this time.
0 commit comments