Skip to content

Instantly share code, notes, and snippets.

@frontenddeveloping
Last active August 29, 2015 14:07
Show Gist options
  • Save frontenddeveloping/5a9bb6082c24480c0f1c to your computer and use it in GitHub Desktop.
Save frontenddeveloping/5a9bb6082c24480c0f1c to your computer and use it in GitHub Desktop.
Async javascript loading (with saving order).
/*
The main feature is script.async = false.
The async IDL attribute controls whether the element will execute asynchronously or not.
So if you will set async to false, scripts will load without blocking user i/o, but scripts will execute synchronously.
Support:
FF 4+
FF for Android All Versions
IE 10+ (starting with preview 2)
Chrome 12+
Chrome For Android All versions
Safari 5.1+
iOS Safari 5.1+
Android Browser 3.0+ (honeycomb on up)
Opera 15.0+
Opera Mobile 16.0+
*/
[
'1.js',
'2.js'
].forEach(function(src) {
var script = document.createElement('script');
script.src = src;
script.async = false;
document.head.appendChild(script);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment