Skip to content

Instantly share code, notes, and snippets.

@codeBelt
Last active August 29, 2015 14:18
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 codeBelt/e96b9f65b9953604338c to your computer and use it in GitHub Desktop.
Save codeBelt/e96b9f65b9953604338c to your computer and use it in GitHub Desktop.
<script type="application/javascript">
function loadJS(file) {
// DOM: Create the script element
var jsElm = document.createElement("script");
// set the type attribute
jsElm.type = "application/javascript";
// make the script element load file
jsElm.src = file;
// finally insert the element to the body element in order to load the script
document.body.appendChild(jsElm);
}
</script>
<button onclick="loadJS('file1.js');">Load file1.js</button>
<button onclick="loadJS('file2.js');">Load file2.js</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment