jQuery 1.4.2 Released

Posted on by

jQuery 1.4.2 is now out! This is the second minor release on top of jQuery 1.4, fixing some outstanding bugs from the 1.4 release and landing some nice improvements.

I would like to thank the following people that provided patches for this release: Ben Alman, Justin Meyer, Neeraj Singh, and Noah Sloan.

Downloading

As usual, we provide two copies of jQuery, one minified (we now use the Google Closure Compiler as the default minifier) and one uncompressed (for debugging or reading).

You can feel free to include the above URLs directly into your site and you will get the full performance benefits of a quickly-loading jQuery.

Additionally you can also load the URLs directly from either Google or Microsoft’s CDNs:

New Features

A full list of the API changes can be found in the 1.4.2 category on the jQuery API site.

In this release we’ve added two new methods: .delegate() and .undelegate(). These methods serve as complements to the existing .live() and .die() methods in jQuery. They simplify the process of watching for specific events from a certain root within the document.

For example:

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

This is equivalent to the following code written using .live():

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

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

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

What’s Changed?

There has been some large code rewrites within this release, both for performance and for fixing long-standing issues.

Performance Improvements

As is the case with virtually every release of jQuery: We’ve worked hard to continue to improve the performance of the code base, making sure that you’re provided with the best performing JavaScript code possible.

According to the numbers presented by the Taskspeed benchmark we’ve improved the performance of jQuery about 2x compared to jQuery 1.4.1 and about 3x compared to jQuery 1.3.2.

jQuery Taskspeed Results (Feb 14, 2010)

Specifically we’ve improved the performance of 4 areas within jQuery:

While comprehensive benchmarks like Taskspeed can be interesting if deconstructed into individual sub-tests for further study, as a project we tend to stay away from using them as an accurate measure of true, overall, library performance. Considering how many aspects make up a library, not to mention the different techniques that they offer, cumulative results rarely reflect how an actual user may use a library.

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. Additionally we saw large gains by optimizing .bind() and .unbind() by a fraction of a millisecond – an inconsequential amount – especially considering that any cases where you would bind hundreds of events you would likely want to use .live() or .delegate() instead.

We’ve collected some results from the other major libraries as well but are less interested in those results and far more interested in the performance improvements that we’ve made relative to older versions of jQuery itself.

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.

Event Rewrite

The largest internal changes have come through a much-needed structural rewrite of the events module. Many quirky issues related to event binding have been resolved with these fixes.

Namely event handlers are no longer stored as object properties in jQuery’s internal object store (with metadata attached to the handlers). Instead they’re now stored within an internal array of objects.

If you’ve ever had the opportunity to play around with .data("events") on a jQuery element you would find that it returns an object with all the event types currently bound, within it.

To enumerate some of the changes that have occurred during this rewrite:

  • It’s now possible to bind identical handlers with different data, namespaces, and event types universally.
  • Execution of event handlers will continue after one handler removes itself (or its sibling handlers).
  • We no longer attach data/namespace information directly to the event handlers (only a unique tracking ID).
  • We no longer 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.

As a side-effect of these changes we had to change the newly-exposed special add/special remove APIs in order to accommodate the new event data objects. Ben Alman is in the process of writing up a large tutorial on jQuery’s special event system and we will be making additional announcements when that occurs.

Bug Fixes

There were a total of 40 tickets closed in this minor release. Some relating to differences between jQuery 1.3.2 and jQuery 1.4.x, some fixing long-standing issues (like in the case of the event module rewrite).

Raw Data

This is the raw data that we collected to generate the aforementioned charts.

	jQuery 1.3.2	jQuery 1.4.1	jQuery 1.4.2	Prototype 1.6.1	MooTools 1.2.4	Dojo 1.4.1	YUI 3.0.0
FF 3.5	2182	806	 565	 2156	 1073	 575	 1885
FF 3.6	1352	677	 519	 2067	 857	 750	 1494
Opera	983	697	 222	 793	 678	 218	 1201
Safari	610	435	 252	 315	 235	 238	 612
Chrome	1591	703	 293	 271	 312	 222	 745
IE 8	2470	1937	 1141	 3045	 4749	 1420	 2922
IE 7	4468	3470	 1705	 9863	 10034	 1737	 5830
IE 6	6517	4468	 2110	 13499	 11453	 2202	 7295

119 thoughts on “jQuery 1.4.2 Released

  1. Pingback: blog.deobald.org » Quergelesen 2010-02-28

  2. Pingback: jQuery 1.4.2 is Out, it’s again blazing fast ! | Whatever to succeed in rails' world

  3. James on said:

    Great stuff but need the vsdoc for Visual Studio. Any idea when that will be ready?

    Thanks,
    James.

  4. jquery floatobject-1.4 breaks my page when I upgrade to 1.4.2, it contains UI accordions (jquery-1.4.2 and jquery-ui-1.8rc3). The following call in floatobject-1.4 breaks;

    var offset = this.jqObj.offset();
    this.currentX = offset.left;
    this.currentY = offset.top;

    JavaScript says:
    offset is null

    if you hardcode 0′s for this.CurrentX and this.currentY, it eliminates any JavaScript errors. I’m not saying that’s a fix or work around, just a clue as to what’s gone wrong.

  5. Pingback: jQuery 1.4.2 – Galeon's Howlingwolf

  6. There has been a great increase in performance.I found delegate() in this release.What is the actual difference between live() and delegate()? Is delegate() having high performance than live()?

  7. Pingback: jQuery: » The Official jQuery Podcast – Episode 15 – John Resig (jQuery 1.4.1 – 1.4.2)

  8. From The Philippines

    wow! makes developer’s life whole lot easier! thanks to jquery and the brilliant minds behind it.

  9. Great work, great performance increases. Looking forward to the Visual Studio vsdoc file – jquery-1.4.2-vsdoc.js. VS IntelliSense makes working jQuery that much easier.

  10. Pingback: Help to IT » Blog Archive » Jquery New version 1.4.2

  11. Awesome! I see from the chart you’ve provided that Jquery runs faster on Safari browsers than on Chrome. That’s a helpful piece of information

  12. Pingback: jQuery 1.4.2 Released - Manmohanjit Singh

  13. marcusklaas on said:

    Woa. Some awesome performance boosts for chrome. I’m loving it. Thanks.

  14. Pingback: Customizable and Flexible jQuery Carousel Rotator – Spookyismy.name

  15. allfakesmiles on said:

    I just started learning Jquery and your Tutorials are amazing
    thanks.

  16. Pingback: Include the Latest Version of jQuery in WordPress without Duplicates - Maverick Web Creations

  17. can I just say, as a self-taught dreamweaver user who is looking for a good picture gallery for my website — yes jquery is the best, but I am absolutely at my wits end trying to work out how to put it into my website…… I am fairly competent at doing the things that are relevant to my needs, and my website is quite nice looking (i think) but I really want to improve my site by adding a good picture viewer and there seems to be NO help out there for someone like me, untrained in HTML code talk…
    I realise that I may be laughed out of this forum, and that I am probably in way over my head, but I literally don’t know where to look or what to look for. You have all this code, but there are NO SIMPLE STEP-BY-STEP INSTRUCTIONS – how do I organise the files? where do I put the code? why can’t I make it work? Why do you have to have a PhD to understand what to do? Or is there some secret code of honour amongst you web people that means you don’t want self taught ‘outsiders’ to gain any knowledge and do things for themselves..?
    can anyone please please help me?

  18. p.s In case anyone takes pity on me (after my rant) and decides to offer me some advice — I am a mac user, and my website (badly in need of updating) is hand-drawnmaps.co.uk

  19. Patrick on said:

    Sorry about my English, I’m from Belgium.
    At this moment I can’t say if it is great or not, i’m learning it.
    I see many laguages of this tutorial, but no dutch one. Can anyone write this in Dutch? So I can understand the English details.
    Thank you
    Patrick

  20. Pingback: Installing JQUERY | JNBCLICK.ORG

  21. Pingback: jQuery 1.4.2 | MicroLibros

  22. Fantastic Framework to work which will make the workload less. Nice to see new version with improved performace.

    Thank you
    Prashanth G

  23. Pingback: The Official jQuery Podcast

  24. I’m trying to downloads jquerry, to my phone. Its a Samsung with
    Jquerry 1.1.having trouble any help?

  25. How come there are still no vsdocs?
    I mean no rush, it’s been _only_ 7 months.
    What a great partnership between MS and you guys.
    This tells us so much about how MS cares about JavaScript support in Visual Studio :(
    Can anyone recommend an IDE with real support for JavaScript?
    Aptana, WebStorm, anything else?

  26. Pingback: gespadas.com » jQuery 1.4.2