Created
December 19, 2017 15:23
-
-
Save franzenzenhofer/03b1b8ed2e0dea25bbc9979c961a3054 to your computer and use it in GitHub Desktop.
nonCirLoad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nonCriLoad = function nonCriLoad() { | |
var rps = document.getElementById('non-critical-css'); | |
if (!(rps.relList && rps.relList.supports && rps.relList.supports("preload"))) { | |
rps.onload = ""; | |
//rps.rel="stylesheet"; | |
var ncs = document.createElement("link"); | |
ncs.rel = "stylesheet"; | |
ncs.href = rps.href; | |
rps.appendChild(ncs); | |
["scroll"].forEach(function (e) { | |
window.removeEventListener(e, nonCriLoad); | |
}); | |
} | |
}; | |
["scroll"].forEach(function (e) { | |
window.addEventListener(e, nonCriLoad, { once: true, passive: true }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment