Skip to content

Instantly share code, notes, and snippets.

@dvidsilva
Last active August 29, 2015 14:17
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 dvidsilva/361eb9eeaaaf7dd93d88 to your computer and use it in GitHub Desktop.
Save dvidsilva/361eb9eeaaaf7dd93d88 to your computer and use it in GitHub Desktop.
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