Created
November 18, 2013 09:30
-
-
Save zanonnicola/7525138 to your computer and use it in GitHub Desktop.
Downloading JavaScript Files in Parallel.
Script by: Rakesh Pai http://blog.rakeshpai.me/2009/03/downloading-javascript-files-in.html
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
<script type="text/javascript"> | |
(function() { | |
var s = [ | |
"/javascripts/script1.js", | |
"/javascripts/script2.js", | |
"/javascripts/script3.js", | |
"/javascripts/script4.js", | |
"/javascripts/script5.js" | |
]; | |
var sc = "script", tp = "text/javascript", sa = "setAttribute", doc = document, ua = window.navigator.userAgent; | |
for(var i=0, l=s.length; i<l; ++i) { | |
if(ua.indexOf("Firefox")!==-1 || ua.indexOf("Opera")!==-1) { | |
var t=doc.createElement(sc); | |
t[sa]("src", s[i]); | |
t[sa]("type", tp); | |
doc.getElementsByTagName("head")[0].appendChild(t); | |
} else { | |
doc.writeln("<" + sc + " type=\"" + tp + "\" src=\"" + s[i] + "\"></" + sc + ">"); | |
} | |
} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment