Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ilikerobots/6e41bb859e54989bf9bad970b7f41229 to your computer and use it in GitHub Desktop.
Save ilikerobots/6e41bb859e54989bf9bad970b7f41229 to your computer and use it in GitHub Desktop.
function load_bundle_file(url, filetype) {
let fileref;
if (filetype === "js") { // build js script tag
fileref = document.createElement('script');
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", url);
} else if (filetype === "css") { // build css link tag
fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", url);
}
if (typeof fileref != "undefined")
document.getElementsByTagName("head")[0].appendChild(fileref);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment