Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Super tiny JS loader
// {Boolean} c Condition
// {String} f File name
var loadjs = function(c,f) {
var l = f.length;
if ( c && f.substring(l - 3, l) === ".js") {
var j = document.createElement('script');
j.type = 'text/javascript';
j.src = f;
j.async = false;
if (typeof j != "undefined") {
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(j, s);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.