2013-09-03, 11:48 AM
Hi,
I'm attempting to asynchronously load my javascript files to speed up load times, but nothing I've tried seems to work correctly.
For example This bit of JS:
Doing a bit of research, I found that to load the JS asynchronously it should look something like this:
However, the above method does not work. I've already searched the forum and other alternative resources and can't seem to find any information on forcing the asynchronous loading of javascript.
Thanks in advance!
I'm attempting to asynchronously load my javascript files to speed up load times, but nothing I've tried seems to work correctly.
For example This bit of JS:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
Doing a bit of research, I found that to load the JS asynchronously it should look something like this:
(function(){
var a = document.createElement('script');
a.type = 'text/javascript';
a.async = true;
a.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
var b = document.getElementsByTagName('script')[0];
b.parentNode.insertBefore(a, b);
})();
However, the above method does not work. I've already searched the forum and other alternative resources and can't seem to find any information on forcing the asynchronous loading of javascript.
Thanks in advance!