jQuery 1.4.2 New Features and Performance improvements

By Partho, Gaea News Network
Monday, February 22, 2010

jqueryjQuery 1.4.2 is out with new features and performance improvements. The latest jQuery release has undergone major bug fixes from 1.4 version. The upgrade is marked by considerable speed up.  It includes significant internal changes, especially the much-needed structural rewrite of the events module. There are a total of 40 tickets addressed in the JavaScript library.  Some long standing issues relating jQuery 1.3.2 and jQuery 1.4.x have also been resolved.  jQuery 1.4.2 adds a list of API changes and improves the coding. Here’s a first impression of the new features and performance improvements.

New Features

Improved API

JQuery 1.4.2 adds two new methods - .delegate() and .undelegate(). These methods would compliment the existing .live() and .die() methods in JQuery. It simplifies the process of watching for specific events from a certain root within a documents.

As with all every jQuery releases, the 1.4.2 also improves upon the performance of the code base ensuring best performance .

JAVASCRIPT:

$("table").delegate("td", "hover", function(){

$(this).toggleClass(”hover”);

});

Using .live() the code becomes

$("table").each(function(){
$("td", this).live("hover", function(){
$(this).toggleClass("hover");
});
});

In .live() is roughly equivalent to the following .delegate() code

$(document).delegate("td", "hover", function(){
$(this).toggleClass("hover");
});

According to the Taskspeed data the performance of jQuery has improved 2x over the 1.4.1 version and nearly 3x as compared to jQuery 1.3.2.

Four changes in performance area

  • The performance of calling .bind() and .unbind(). (Ticket)
  • The performance of .empty(), .remove(), and .html(). (Ticket)
  • The performance of inserting a single DOM node into a document. (Ticket, Additional Commit)
  • The performace of calling $(”body”). (Commit)

The comprehensive results from the tests of Taskspeed can be fragmented further to interpret the overall performance of
It’s feasible to consider the different aspects that make up individual sub-tests for further study. Consider the aspects that make library. Don’t mention the different techniques that they offer,

For example, we saw significant overall performance speed-ups in Taskspeed simply by optimizing the $(”body”) selector because it’s called hundreds of times within the tests.

This could only be relevant for apps that need to call $(”body”) several times

Rewrite of events module

Largest internal change introduced in jQuery is the structural rewrite of the events module. A number of quirky issues have been addressed in the new fixes.

The event handlers are no longer stored as object properties in jQuery’s internal object store including metadata). They now store an internal array of objects.

Here are the changes that have occurred during the rewrite

  • It is easier to bind the identical handlers with different data, namespaces and event types universally
  • Execution of event handlers will continue even after removing a handler itself
  • No attach data/namespace information directly to the event handlers (only a unique tracking ID).
  • No use proxy functions, internally, to try and encapsulate handlers.

Execution order of events is now guaranteed in all browsers. Google Chrome had a long-standing error in their object-looping logic that has been routed around.

Bug Fixes

In this release there were more than 40 tickets addressed in jQuery

jQuery aims to continue with its improvements. As provided by jQuery blog,

We will continue to work on optimizing the jQuery code base – indefinitely. It’s always a major concern for us to try and provide the fastest JavaScript/DOM-development experience possible. And yes, there will likely always be ways to gain additional performance – either through internal optimizations or by pushing critical functionality off into browser-land for standardization.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :