Defer jQuery Load



(function() {
     function async_load(){
         var s = document.createElement('script');
         s.type = 'text/javascript';
         s.async = true;
         s.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
         var x = document.getElementsByTagName('script')[0];
         x.parentNode.insertBefore(s, x);
     } 
     if (window.attachEvent) window.attachEvent('onload', async_load);
     else window.addEventListener('load', async_load, false); 
 })();


This is a snippet that demonstrates how jQuery can be delayed or defered until the web page and DOM are fully loaded so as to enhance perfomance.Your code utilising the jQuery $() global object should also be loaded in the same way but when writing your jquery code,do not bind it to the onready event $(document).ready(function(){ ..; method but rather omit it..