Compressed
Uncompressed
ImprovementsA number of improvements have gone into this release, in addition to all of the normal
bug fixes.
Any Name jQueryjQuery has taken a big step to become the first major JavaScript library completely capable of renaming itself. Previously, functionality was provided to rename the oft-used ‘$’ shortcut for ‘jQuery’ - but now you can also rename both ‘$’ and ‘jQuery’. This allows for two fantastic results:
- You can now include multiple versions of jQuery, simultaneously, on the same page.
- You can now embed jQuery into the namespaces of other objects and libraries, for example: // With the Dojo Toolkitdojo.jquery = jQuery.noConflict(true);dojo.jquery("#elem div").slideDown("slow");// or with Yahoo UIYAHOO.query = jQuery.noConflict(true);YAHOO.query("span.hidden").removeClass("hidden");
Speed ImprovementsWhat would a release be without some speed improvements? We took the opportunity to step beyond any previously-released speed test suites and improve the speed of the three most commonly used portions of jQuery: ID selectors, tag name selectors, and each() loops. It’s absolutely critical that each of these items are made as fast as possible, as they have the possibility of being re-used endlessly, and repeatedly.
Here’s the
test suite used to analyze the speed of the three changes.
$(”#id”) Improvements
[tr]BrowserjQuery 1.1.3jQuery 1.1.4% Improvement[/tr][tr]IE 6[td]651ms| 70ms[/td]830%[/tr][tr]Firefox 2[td]1355ms | 27ms[/td]4919%[/tr][tr]Safari 3[td]101ms | 14ms[/td]620%[/tr][tr]Opera 9[td]270ms | 62ms[/td]335%[/tr] | | Average improvement:[/td]1676%[/tr] |
$(”elem”) Improvements
[tr]BrowserjQuery 1.1.3jQuery 1.1.4% Improvement[/tr][tr]IE 6[td]661ms| 451ms[/td]47%[/tr][tr]Firefox 2[td]1717ms | 143ms[/td]1100%[/tr][tr]Safari 3[td]99ms | 83ms[/td]19%[/tr][tr]Opera 9[td]226ms | 198ms[/td]14%[/tr] | | Average improvement:[/td]295%[/tr] |
.each() Improvements
[tr]BrowserjQuery 1.1.3jQuery 1.1.4% Improvement[/tr][tr]IE 6[td]200ms| 30ms[/td]567%[/tr][tr]Firefox 2[td]468ms | 29ms[/td]1514%[/tr][tr]Safari 3[td]17ms | 11ms[/td]54%[/tr][tr]Opera 9[td]45ms | 25ms[/td]80%[/tr] | | Average improvement:[/td]554%[/tr] |
Test Suite OverhaulThis is very big news - and should be especially so to most developers out there. The
jQuery test suite has been completely re-tooled and improved from the ground up for stability. A brand new swath of Animation and Ajax tests have been integrated bringing jQuery’s total test count to
over 800 tests!
Additionally, the
test suite completely passes with no errors in all the major browsers that we support: Firefox 2, Safari 3, Internet Explorer 6, and Opera 9. Proof:
In the future, we’re working to improve our coverage of the Event, Attribute, and CSS portions of jQuery - undoubtedly bringing us to over 1000 tests very soon.
Additionally, it should be noted that the jQuery test suite is now embedded in the Mozilla test suite - running against every commit of the upcoming Firefox 3 release. You can feel safe knowing that in the newest release of Firefox, everything will just keep working, as you would expect it to.
Bug Fixes
53 tickets have been closed for this release. You can read the full details on the
the bug tracker (this includes fixes that went in to jQuery 1.1.3.1).
A bunch of large issues were resolved, including issues related to HTML script evaluation, Safari CSS Computed Style access, and Ajax settings manipulation.
New FunctionalityA couple pieces of new functionality have been introduced. The first two of which, .slice() and :has(), are going to be a part of
jQuery 1.2, but their existence is obligated by some deprecated functionality (see below). The new changes to extend() and noConflict() were put in order to be able to fix some long standing bugs in jQuery.
.slice()You may recognize this method name from the .slice() method that exists on JavaScript arrays - you’re in luck because it behaves identically. This is a great method for chopping apart jQuery objects and getting to the elements inside of them. All of the following are valid ways to use the slice() method:
$("div").slice(0,1); // First div$("div").slice(-1); // Last div$("div").slice(1,-1); // All divs but the first and last$("div").slice(1,3); // The second and third div$("div").slice(7,8); // The eighth div:has()This new selector is a replacement for the current way of checking for elements inside of another element (div[p]). You can now use this selector just as you would that particular XPath selector, like so:
// All divs with a paragraph inside$("div:has(p)")// All anchors with an image inside$("a:has(img)")// All divs that have an anchor inside that have an image inside$("div:has(a:has(img))")Deep, resursive .extend()This has been a frequently-requested addition to the jQuery .extend() method. This change allows you to deeply merge nested objects (as opposed to having them overwrite each other). This is best demonstrated through an example:
//
Normal .extend()jQuery.extend( { name: “John”, location: { city: “Boston” } }, { last: “Resig”, location: { state: “MA” } });// Result:// => { name: “John”, last: “Resig”, location: { state: “MA” } }//
New Deep .extend()jQuery.extend( true, { name: “John”, location: { city: “Boston” } }, { last: “Resig”, location: { state: “MA” } });// Result:// => { name: “John”, last: “Resig”,// location: { city: “Boston”, state: “MA” } }.noConflict(true)As described previously, this addition to .noConflict() allows you to completely rename both the ‘jQuery’ namespace and the ‘$’ shortcut, while also rolling back any changes those introductions may have done. You can use this new shortcut like so:
// Give jQuery a custom name:var jq = jQuery.noConflict(true);jq("#id div").hide();// Both Fail - $ and jQuery have been renamed

("#id div").hide();jQuery("#id div").hide();This trick can also be used to push jQuery into an existing namespace, like so:
// Put jQuery in a namespace:var obj = {};obj.jq = jQuery.noConflict(true);obj.jq("#id div").hide();