Last active
August 29, 2015 14:23
-
-
Save andreasvirkus/50b07ee690bcd01ff07a to your computer and use it in GitHub Desktop.
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
// add this as the only script before your closing body tag | |
// and let it load your external scripts once your DOM has finished loading. | |
function addJSOnload() { | |
var element = document.createElement("script"); | |
element.src = "defer.js"; // replace your script with "defer.js" | |
document.body.appendChild(element); | |
} | |
if (window.addEventListener) | |
window.addEventListener("load", addJSOnload, false); | |
else if (window.attachEvent) | |
window.attachEvent("onload", addJSOnload); | |
else | |
window.onload = addJSOnload; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment