Load jquery.js async - possible?
I'm using
http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js on my site. Is it possible to load it asynchronously?
Like Google Analytics:
- (function() {
- var ga = document.createElement('script');
- ga.src = ('https:' == document.location.protocol ?
- 'https://ssl' : 'http://www') +
- '.google-analytics.com/ga.js';
- ga.setAttribute('async', 'true');
- document.documentElement.firstChild.appendChild(ga);
- })();
I think the big difference between ga.js and jquery.js is that
- Google Analytics doesn't modify the DOM
- No other scripts are depending on ga.js
Of course, since I'm using jquery, I want to modify the DOM. And I also have other scripts that depends on jquery. Does it matter?
Is there a way for me to load jquery.js asynchronously. And maby also other scripts on the same page, that depends on jquery to be loaded?
Are there any downsides?