Skip to content

Instantly share code, notes, and snippets.

@dvidsilva dvidsilva/appendscript.js
Last active Aug 29, 2015

Embed
What would you like to do?
Add a js file based ona variable
document.addEventListener("DOMContentLoaded", function() {
var src, scriptTag;
src = "./app.js"; // here goes the name of the file to include
scriptTag = document.createElement('SCRIPT');
scriptTag.src = src;
document.body.appendChild(scriptTag);
});
var src, scriptTag;
src = "./app.js"; // here goes the name of the file to include
scriptTag = document.createElement('SCRIPT');
scriptTag.src = src;
document.getElementsByTagName('head')[0].appendChild(scriptTag);
var src;
src = "./app.js"; // here goes the name of the file to include
document.write('<script src="'+src+'"></script>');
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.