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: jQuery 1.4.2 Released | Dev Loom

  2. Pingback: Launching jquery 1.4.2 « Ninofs menumpang

  3. Wow, the performance improvements are overwhelming.

    One question. Can anyone write good tutorial about how core of jQuery works, something like “The core of JQuery for dummies”. I think that understanding of the core.js of JQuery can help many of us to write better jQuery code or better plugins.

  4. That raw data chart looks pretty crappy! would love to see the comparisons lined up in a table instead of a pre tag =]

  5. Pingback: Ajaxian » jQuery 1.4.2: performance and a few APIs

  6. Krzysztof Tarnowski on said:

    I think that delegate()/undelegate() should completely replace live()/die():
    - live/die can be implemented using delegate/undelegate (potential feature bloat).
    - delegate and undelegate naming scheme is more consistent than live/die pair.

  7. Pingback: jQuery ????????? ?? ?????? 1.4.2- R@Me0!'s blog

  8. Pingback: jQuery 1.4.2 is out « Wasim Farhat Blog

  9. Pingback: jQuery 1.4.2 Released | Lick My Chip !

  10. Pingback: jQuery: » Page not found

  11. Thank you John Resig, Ben Alman, Justin Meyer, Neeraj Singh, and Noah Sloan for 1.4.2.
    And John, thanks for creating this post explaining it. With examples, and charts, and thoughts on importance. All organized nicely to pour straight into my brain. I appreciate the quality.

  12. Pingback: Devteca » jQuery 1.4.2

  13. Pingback: Javascript jQuery plugins visualizations don’t look half bad » Victus Spiritus

  14. Pingback: jQuery 1.4 | uebbi.com

  15. Mike Howard on said:

    Here’s an HTML version of the raw data table:

     
    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

  16. Pingback: jQuery accellère avec sa version 1.4.2

  17. Pingback: jQuery 1.4.2 released (Perform… | BrettSinclair.net

  18. Pingback: MT22???? -

  19. Pingback: jQuery 1.4.2 ??????? | ??

  20. Pingback: JQUERY 1.4.2 RELEASED | jQuery Tutorials in Thailand.

  21. Pingback: The Morning Brew - Chris Alcock » The Morning Brew #544

  22. Pingback: [Brève] JQuery 1.4.2 s’annonce avec des nouveautés - Websourcing.fr

  23. Pingback: Slickspeed mit aktuellen JS-Versionen | web.dev.blog

  24. Pingback: jQuery 1.4.2 ??????? « Galcier's Blog

  25. Pingback: jQuery 1.4.2 erschienen - Notes, Release, Funktion, Download, Interessante, jQuery-Blog, Infos, Elementen - homepagebewertung.de

  26. Jeffrey Gilbert on said:

    Outstanding. Would be awesome to see a larger historical performance comparison dating back to the early releases of jquery (1, 1.2, 1.3, etc). I know there were similar graphics back then before JQuery had quite this much love.

  27. Pingback: jQuery 1.4.2 comes with performance improvements! | stoimen.com/blog

  28. Pingback: Waebo » jQuery 1.4.2 : Meilleures performances pour le framework JavaScript

  29. Pingback: Fresh From Twitter | mobile geo social

  30. FYI the link to “Tutorials” here on this Web site is throwing a database error:

    A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:

    (SQL query hidden)

    from within function “MediaWikiBagOStuff::_doquery”. MySQL returned error “1205: Lock wait timeout exceeded; try restarting transaction (localhost)”.

  31. Pingback: jQuery 1.4.2 « PHP Portal