Improvement and speed up tips for JQuery
Posted by admin on September 15 2010 05:59:51

1. It's good idea when you develop some application with jQuery to use cheat sheet.

On the net you could find cheat sheets for jQuery. Here are listed some cheat sheets for jQuery:


http://www.gscottolson.com/jquery/jQuery1.2.cheatsheet.v1.0.pdf

http://www.javascripttoolbox.com/jquery/cheatsheet/JQueryCheatSheet-1.3.2.pdf

http://labs.impulsestudios.ca/downloads/impulse_studios-jquery_cheat_sheet-1.0.pdf

http://colorcharge.com/jquery/

http://www.javascripttoolbox.com/jquery/cheatsheet/JQueryCheatSheet-1.1.3.pdf


  1. Several JavaScript libraries are hosted by Google. There are several advantages to loading them from Google instead of from your server. Saves on bandwidth, load very quickly from Google's and most importantly it'll already be cached if the user has visited a site which delivers it from Google Code.

     

Here is an example for loading of jQuery from Google:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>


3. Keep DOM manipulation to a minimum

4. IDs instead of classes wherever possible

jQuery makes selecting DOM elements using classes as easy as selecting elements by ID used to be, so it's tempting to use classes much more liberally than before. It's still much better to select by ID though because jQuery uses the browser's native method (getElementByID) to do this and doesn't have to do any of it's own DOM traversal, which is much faster.