Friday, August 24th, 2007
jQuery 1.1.4: Faster, More Tests, Ready for 1.2
In preparation for their upcoming jQuery v1.2 release next month, the jQuery team has released jQuery v1.1.4, an interim release which:
- Increases selector performance
- Includes an over-hauled test suite
- Provides the ability to embed jQuery into the namespaces of other objects and libraries
- Introduces the new method .slice() & new select :has()
- Corrects some bugs
Of note is the library’s capability to rename itself:
Any Name jQuery
jQuery 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 Toolkit
dojo.jquery = jQuery.noConflict(true);
dojo.jquery(“#elem div”).slideDown(“slow”);
// or with Yahoo UI
YAHOO.query = jQuery.noConflict(true);
YAHOO.query(“span.hidden”).removeClass(“hidden”);





We had had to do a workaround in our auto-login tool in order to compensate for this, so this was indeed a great fix and a time saver.
Sorry, I was totally unclear…
I was referring to the ability to embed jQuery into the namespaces of other objects and include multiple versions of jQuery on the same page.
Cheers,
Tara
What is the benefit of using mutiple versions of jquery?
@rizqi: i guest it’s just possibility taken from this release :D
@Rizqi: There’s no benefit, if you have complete control over a site. But if you work in a situation where you have no control over what else is in the site (which can frequently be the case in large corporations), you can now feel safe knowing that your copy of jQuery will still work.
Additionally, it’s good because you can now inject jQuery into any web site, and it’ll still work. (Some people have written Firefox extensions to inject jQuery into random web pages – so this will help them.)
I love it when things I like get even faster! Mmm speed increase.
@Rizqi:
In the event that jQuery is written into say, Firefox extensions, or if jQuery is loaded with GreaseMonkey, and then you visit a webpage ALSO using jQuery, the namespace prevents collision. You could also run two versions of jQuery, i.e. a stable version and a beta, for testing on the same html/js without making two separate pages. Or if jQuery is written into a Widget, and that widget placed inside a page which uses jQuery…. The list goes on
$.fn.can = function() {return self}
now, we can work in style
$(‘div’).can.has(‘p’)
i’ve always wanted to be able to do that. thank you jQuery!.
@carmen: :has() [not .has()] must be inside the $(), as seen below.
Together with the deep extend & noConflict, we can finally allow the ever popular:
/* jQuery lolcatz plugin 0.2b */
(function($) {
$.cheez = { taste: "delicious" };
$.extend(true, $, { cheez: { burger: "span" } } );
$$ = jQuery.noConflict(true);
})(jQuery);
$$( function() {
if ( $$('i.can:has(' + $$.cheez.burger+')' ) ) alert($$.cheez.taste);
});
})(jQuery);
Previously efforts to extend cheez on to burgers was destroying taste.
This plugin, soon to be released, allows guaranteed, no-conflict, cheezburger delivery.
Damn $(“#id”) is 10 times faster?! How could you get any faster than document.getElementById?
@Jordan: We can’t :-) Right now $(“#id”) is only about 10% slower than $(document.getElementById(‘id’)). And we really can’t get any faster than that (as we have to do a RegExp to verify the selector’s contents). I consider 10% to be a reasonable amount of overhead over pure DOM scripting.
@John Resig:
Out of curiosity, are there optimizations for the case of getting just 1 element, such as: $(“div.blue:eq(0)”)? Or will jQuery get all $(“div.blue”) first and then pop the first element?
http://experiment.bcse.info/slickspeed/
Don: wow, base2.DOM is the fastest one in IE7, Opera 9.2, Firefox 1.5 and Safari 3 here :|
Mister Edwards: let all the libraries accidentally steal your code please.. Or am I missing something?