Created
July 26, 2012 04:20
-
-
Save orangexception/3180235 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
// A better way to load your JavaScript. I've shared this on Google+ before. Emil Stenstr?m created the script and explains everything on his post, (Lazy Loading Asynchronous JavaScript)[http://friendlybit.com/js/lazy-loading-asyncronous-javascript/] | |
<script type= "text/javascript"> | |
(function() { | |
function async_load() { | |
var s= document.createElement('script'); | |
s.type= 'text/javascript'; | |
s.async= true; | |
s.src= 'http://c322385.r85.cf1.rackcdn.com/application.js'; | |
var x= document.getElementsByTagName('script')[0]; | |
x.parentNode.insertBefore(s, x); | |
} | |
if ( window.attachEvent ) { | |
window.attachEvent( 'onload' , async_load ); | |
} | |
else { | |
window.addEventListener( 'load' , async_load , false ); | |
} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment