jQuery – Fast, Light-weight Javascript Library

A javascript library is a collection of functions and methods in Javascript for performing some of the most common needs like Dom traversing, event handling, adding Ajax interaction etc. There are many free Javascript libraries available like jQuery, Prototype, Scriptaculous, Dojo, MochiKit, Yahoo! UI Library (YUI). Prototype and Scriptaculous together forms the backbone of the Ruby-on-Rails project. YUI is a free set of utilities and controls supported by Yahoo!. Dojo Toolkit is a library having Java like syntax. All the libraries have their own highs and lows.

Recently jQuery has started getting a lot of attention. jQuery is a fast and extremely lightweight Javascript library. Recently jQuery v1.1.3 was released, which is said to be upto eight times faster than the previous version. But the biggest advantages is that the size of the library when compressed is just 20KB. Don’t you think that is great? Drupal 5.0 is using jQuery instead of the older drupal.js.

Another advantage is that jQuery can be used with other Javascript Libraries without conflict. It also has a clean and modular approach to plugins. Since writing plugins is very simple in jQuery, a number of plugins are available for most of the common uses.

With jQuery running an animation like sliding and fading are very simple. Interface is a jQuery plugin for animation. Interface is like scriptaculous library for prototype. It can be used for handling sorting, drag and drop effect and other complex effects.

Another important feature of jQuery is the ready function. For Dom scripting we have to wait till the complete Dom loads. Using the onload event handler for this purpose is a waste of time for pages having images as the event is triggered only when every element, including the images, have been loaded. jQuery provides a workaround, ie the ready function, which is called when the dom has loaded completely.

Sending and retrieving data via ajax has never been easier. jQuery provides us with a rich set of functions for managing it.

jQuery has a really simplified format for traversing the Dom. jQuery’s selector syntax is based heavily on CSS3 and XPath. Hence selecting and traversing through elements have never been simpler. Elements can be selected using id, classname, a combination of id and classname and XPath reference.

Another important feature of jQuery is method chaining. Every call of a method on a jQuery object returns the object itself. Hence to apply multiple methods to an element you can do it without typing the selector again. All you have to do is to chain the new method at the end of the previous method.

jQuery has made Javascript programming fun and enjoyable for me. Try it and feel its power.

Links

2 thoughts on “jQuery – Fast, Light-weight Javascript Library

  1. Hello, I found this post while searching for help with JavaScript. I’ve recently changed browsers from Opera to IE. After the change I seem to have a problem with loading JavaScript. Every time I browse website that needs Javascript, my computer freezes and I get a “runtime error javascript.JSException: Unknown name”. I cannot seem to find out how to fix it. Any help is very appreciated! Thanks

Comments are closed.