Skip to content

Instantly share code, notes, and snippets.

@jdrydn
Last active Dec 17, 2015
Embed
What would you like to do?
/**
* 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