Created
May 15, 2013 07:49
-
-
Save skatebkp/5582271 to your computer and use it in GitHub Desktop.
5. Defer loading of JavaScript If you must use JavaScript, then it is a good idea to defer the loading of this code until after the page load event has fired. Google actually provides a deferral script you can use to do this: codesource
// Add a script element as a child of the body
function downloadJSAtOnload() { var element = document.createEl…
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
| // Check for browser support of event handling capability | |
| if (window.addEventListener) | |
| window.addEventListener("load", downloadJSAtOnload, false); | |
| else if (window.attachEvent) | |
| window.attachEvent("onload", downloadJSAtOnload); | |
| else window.onload = downloadJSAtOnload; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment