Skip to content

Instantly share code, notes, and snippets.

@jdrydn
Last active December 17, 2015 04:19
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 jdrydn/5549822 to your computer and use it in GitHub Desktop.
Save jdrydn/5549822 to your computer and use it in GitHub Desktop.
/**
* A really nice way to dynamically load JavaScript files.
* Place this at the bottom of HTML files to load JavaScripts after pageload! :)
*
* The cake is still a lie.
*/
(function(d, scripts){
for(var id in scripts) if (d.getElementById(id) == null) {
var js = d.createElement('script'); js.id = id; js.src = scripts[id];
d.body.appendChild(js);
}
}(document, {
"jquery": "//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js",
"moment": "//rawgithub.com/timrwood/moment/2.0.0/min/moment.min.js",
"advice": "/js/advice.js"
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment