Created
October 17, 2011 08:30
-
-
Save unlight/1292203 to your computer and use it in GitHub Desktop.
Include javascript file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function include(files) { | |
if (typeof(files) == 'string') files = [files]; | |
var onload; | |
var script = document.createElement('script'); | |
var file = files.shift(); | |
script.setAttribute('type', 'text/javascript'); | |
script.setAttribute('src', file); | |
document.body.appendChild(script); | |
if (files.length > 0) { | |
onload = function() { include(files); } | |
script.onreadystatechange = onload; | |
script.onload = onload; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment