I have searched the web, found some answers but none of them work. All i want for my site to load faster. I have minified my images. Now am using jquery and used version hosted by google. Though it's not hosted on my site, it's the heaviest file (32kb) in the site and it loads 2nd on the line before any other images. I have tried the adding a javascript before the body closing tag like this:
<script language="javascript">
var e=document.createElement('script');
e.setAttribute('type','text/javascript');
e.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
document.body.appendChild(e)
var f=document.createElement('script');
f.setAttribute('type','text/javascript');
f.setAttribute('src','myjs.js');
document.body.appendChild(f)
</script>
On firebug console, it shows that jquery is loaded last. However it also shows uncaught reference error $ not defined, which am guessing an error you get when jquery isn't loaded properly.
If i put these two js files inside the head tag, everything works fine.
How can I accomplish this task?
thanks.