-
-
Save molotow11/c8c33e7d5320094757f01c60c5548ce8 to your computer and use it in GitHub Desktop.
Defer scripts loading
This file contains 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 scriptsLoadDelay = 10000; | |
var delayedScripts = [ | |
"https://w.sharethis.com/button/buttons.js", | |
]; | |
setTimeout(function() { | |
console.log("Delayed scripts loading"); | |
for(var i=0; i<delayedScripts.length; i++) { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.async = true; | |
script.src = delayedScripts[i]; | |
console.log("Delayed: " + delayedScripts[i]); | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(script, s); | |
} | |
}, scriptsLoadDelay); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment