jQuery 1.4 Performance Improvements
Posted by Craig Ceremuga
on Tuesday, January 19, 2010
Hello friends, it's that time again, jQuery has released its latest version! jQuery 1.4 is now available and includes new features and improvements on old favorites! Perhaps you're thinking "What's the big deal, I'm a Javascript master, I can do all this stuff by hand!" Sure, that might be the case, but you're probably wasting time and money writing the same old thing over and over and over again when a time-tested and well produced Javascript library could do all the work for you!
If you're not familiar with jQuery and / or Javascript libraries, the basic overview is that they take all of your usually mundane client-side programming techniques and spice them up a bit reducing code clutter, improving efficiency and reducing bugs. You really can't argue with that. Here's a quick example for those who don't know jQuery before I move on to the improvements in 1.4. Let's say you need a quick onclick function for a button that changes the text inside a block-level item in your code with an ID of MyFunDiv.
In normal Javascript, you could do something like this:
document.getElementById("MyFunDiv").innerHTML = "Yay!";
In jQuery all you need to do is this:
$("#MyFunDiv").html("Yay!");
It's simple, it's elegant, it's concise, it's jQuery! Alright, enough of the basics, onto the improvements for seasoned veterans.
The biggest change in 1.4 is major performance improvements of some of the most popular methods. The team worked hard to significantly reduce the complexity of the internal code, thereby improving performance across the board. Here's a little graph illustrating the number of function calls being made for some of the most popular methods:

Another improvement which is very nice is speed increase to the .css() method. This method has been improved across the board on almost all major browsers (IE 7 seeing the smallerst improvements).

There are a whole bunch of new features and improvements that I don't want to go into detail since the official site explains them all to the fullest extent possible. All in all, the jQuery team has fixed 207 bugs in this release which is more than double the 97 bugs that were fixed in the 1.3 release. As always, you can easily add jQuery to any HTML document via Google's fine hosting by simply doing this:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
Using Google's hosted version improves pageloads since there's a pretty good chance the Google content delivery network is faster than your server's connection and if someone has visited another site that uses jQuery from Google, it will probably be in their browser cache already and they won't have to download it again. The full release notes can be found on the jQuery Website .
Care to Comment?