Created
April 28, 2011 07:30
-
-
Save chrishamant/945956 to your computer and use it in GitHub Desktop.
Simple asyncscript loader
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
#analytics stuff | |
_gaq = [['_setAccount','UA-XX-1'],['_trackPageview']] | |
d = window.document | |
l = d.location | |
scripts = [ | |
'//google-analytics.com/ga.js', | |
'//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', | |
'//' + l.host + '/js/site.js' | |
] | |
getScript = (src)-> | |
s = d.createElement 'script' | |
s.async = true | |
s.src = src | |
e = (d.getElementsByTagName('script')[0]) | |
e.parentNode.insertBefore(s,e) | |
getScript(script) for script in scripts |
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
#this is the kind of thing you'd need to do in site.js before you can expect jQuery to work | |
# what if your site.js loaded before jQuery? | |
if jQuery then init() else window.setTimeout(ready,0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment