Skip to content

Instantly share code, notes, and snippets.

@lafikl
Last active December 16, 2015 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lafikl/5480809 to your computer and use it in GitHub Desktop.
Save lafikl/5480809 to your computer and use it in GitHub Desktop.
Load Scripts asynchronously.
function LoadScriptsAsync (src) {
if(!src) throw new Error('LoadScriptsAsync : You have to add a script src!');
var script = document.createElement('script'),
head = document.getElementsByTagName('head')[0];
script.type = "text/javascript";
script.src = src;
script.async = true; // new property in HTML5 : http://davidwalsh.name/html5-async
head.appendChild(script);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment