jQuery 2.0 Beta 2 Released
The next beta of jQuery 2.0 has arrived! This beta has several changes and tweaks based on the feedback we received from those of you who generously tested the first beta. We really need you to test this version as well and let us know what still needs to be done. We believe this version is very stable and ready for you to try; don’t wait until the final release and then find out your code doesn’t run with it.
Remember that jQuery 2.0 will not run on IE 6, 7, or 8; we’re saving that duty for jQuery 1.9. We fully expect that most Internet web sites may continue to use jQuery 1.x for quite a while, as long as older versions of IE still comprise a large proportion of web surfers. And so the jQuery team will also continue to support both the jQuery 1.x and 2.x lines. Don’t feel like you’re missing something or falling behind by using 1.9 on your web site, since the APIs for 1.9 and 2.0 are the same.
If you’d like to try jQuery 2.0 on web sites where you still need to support IE 6, 7, and 8, you can use conditional comments. All browsers except old IE will get the second script and ignore the first:
<!--[if lt IE 9]> <script src="jquery-1.9.1.js"></script> <![endif]--> <!--[if gte IE 9]><!--> <script src="jquery-2.0.0b2.js"></script> <!--<![endif]-->
There are lots of other environments where jQuery 2.0 should fit in very well. Here are a few suggestions:
- Google Chrome plugins
- Mozilla XUL apps and Firefox extensions
- Firefox OS apps
- Chrome OS apps
- Windows 8 Store (“Modern/Metro UI”) apps
- BlackBerry 10 WebWorks apps
- PhoneGap/Cordova apps
- Apple UIWebView class
- Microsoft WebBrowser control
- Cheerio or jsdom with node.js
- Intranet applications
On the node.js front, the jQuery team now owns the “jquery” and “jQuery” names in npm and will soon be shipping 2.0 releases there.
You can get this latest beta from the jQuery CDN:
To run pre-1.9-era code with jQuery 2.0, you can also use the jQuery Migrate plugin to restore deprecated features from those older versions and/or diagnose compatibility issues. We strongly recommend that you do use Migrate for older code, it will save a lot of time and trouble in debugging.
Lots of bug fixes: All the relevant fixes from jQuery 1.9.1 and 1.9.2pre have been incorporated into jQuery 2.0 beta 2. We sadly had to back out some optimizations that aren’t supported by older versions of WebKit such as Android 2.3, but most of those didn’t have a significant size impact. Still, we plan to bring them back as soon as we can! To help us out, anytime you see an old Android phone you can “accidentally” whack it with a hammer.
New .data() implementation: This new code is a complete rewrite by Rick Waldron. It’s smaller, simpler, and much more maintainable than the old code.
Increased modularity in custom builds: You can now exclude all the redundant event shorthands such as
.mouseover(...) if you’re willing to use
Minimal selector engine: Richard Gibson created a small wrapper around the browser’s native
matchesSelector APIs that can be used as a replacement for the full-fledged Sizzle selector engine. Be aware, however, that there are major differences in the supported selectors and semantics. This minimal engine does not support jQuery selector extensions like
:first for example.
We’d love for you to try out the custom build system which is based on grunt. The README gives more detail on making a custom build. As of beta 2 you can replace Sizzle with a simple selector engine and exclude css, event aliases, animations, offset, and deprecated functionality such as
.andSelf() that has not yet been removed. In addition you can exclude a subset of the script, JSONP, or XMLHTTPRequest transports. That’s right, reject any module in our jQuery reality and substitute your own.
Here is an example of what you can save with modular builds. Let’s say you don’t need the css, offset, dimensions, or deprecated modules and plan to do animations completely via CSS transitions and classes. In addition you only use JSONP via
$.ajax(). You’ll use
.on() for event management and keep your selectors simple so that the minimal selector engine can do the job. The build command to do that is:
The resulting file from that custom build is just 17,530 bytes when transferred by gzip, which is 40 percent smaller than the full 2.0 build at 29,387 bytes gzipped. For comparison, the current 1.9 branch is 32,770 bytes gzipped.
We still think that the vast majority of jQuery users are best served by the simplest option: Use the full version of jQuery, served from a CDN or your local server. Most jQuery plugins are not written in a way that would allow you to use a subset of jQuery core functionality — after all, they never anticipated any of it would be missing! But for situations where it’s worth the time to determine those dependencies, jQuery’s current level of modularity offers awesome flexibility.
Many thanks to the people who contributed fixes to this release: Adam Coulombe, Andrew Plummer, Danil Somsikov, Dmitry Gusev, Isaac Schlueter, James Burke, Jean Boussier, Julian Aubourg, Karl Sieburg, Mark Raddatz, Mike Sherov, Nguyen Phuc Lam, Oleg Gaidarenko, Pascal Borelli, Richard Gibson, Rick Waldron, Ryunosuke Sato, Timmy Willison, and Timo Tijhof. Special recognition to Scott González for his minimalist work simply titled, “Whitespace“.
- #13388: Ajax request not returning responseXML
- #13276: In IE 9/10 $.parseXML() returning document object instead of XMLDOMDocument
- #13292: $.ajax with 1.9.0 doesn’t call anymore success function in case of 204
- #13306: File input added to serialized forms caused a change in behavior and only halfway follows spec
- #12656: Make event shorthands an excludable module
- #13316: Check against jquery.min.js with TestSwarm
- #13335: “use strict”; break asp.net ajax postacks in FF
- #12846: overflow:hidden is not removed when .stop() is called
- #13183: Wrong animation initial value calculation (1.9.0rc1)
- #13143: e.target can be a text node on mousewheel
- #13360: Creating String.prototype.namespace can cause an exception in jQuery.Event
- #13232: In 2.0beta1, using html() function on a tbody selector yields insertion of new tbody
- #13233: Unexpected behavior when iterating over and manipulating detached nodes in jquery 1.9
- #13282: QtWebKit — TypeError: ‘[object Object]’ is not a valid argument for ‘Function.prototype.apply’ (evaluating ‘elem.nodeType’)
- #13434: Create querySelectorAll/matchesSelector selector option
- #13331: jQuery.fn.add returns incorrect order in Chrome and Safari
- #13420: jQuery 1.9.1 fails to filter SVG parent nodes by class name when using .parent() and .closest()
- #13499: Descendant selector fails when searched ID doesn’t exists but NAME does (IE7 only)
- #13505: jquery#add: seems to get items in collection out of order on larger lists
- #10814: make support as lazy as possible with closure in mind
- #12040: Test against Content Security Policy (CSP)
- #13089: support adds zoom style to body in Chrome/Safari
- #13265: parent method fails with text nodes in IE10
- #13332: .closest(“*”) yields input even for non-element nodes
- #13349: find function slower since 1.9.0, especially in chrome
Scott González is my new hero!
This is great news! I especially like the custom builds. Modularity FTW
Thank you guys we love jQuery!
This is great news specially for mobile developers. Parsing times will hopefully be cut in half with this release.
I’m hopping the JQM team will make the best use of this new custom build system and make it work with their own custom build system. So that we can generate a single and more efficient peace of code.
Is it me or do the conditional statements above mean IE9 doesn’t get jQuery at all??
_jquery 2.x not running on anything<=IE8,totally awesome.
@Ben Squire: gte means “greater than or equals”, so IE9 gets jQuery 2.0 with this conditional statement
You guys are great!
You still can’t compare Zepto.js and jQuery 2 file size, 10.9?KB vs 29.1?KB compressed gzipped file size. jQuery is almost 3x bigger.
@Binyamin: What do you think is in that difference? Zepto would have a similar size if it addressed the issues the jQuery community fixed over the years. Filesizes like this should be a non-issue, stability is what matters.
If Zepto sticks around, it’ll just grow to similar filesize. I doubt it will though because people know better. Do yourself a favor and go for something stable.
The difference between jquery 1.9 and 2,0 is less than 3.4 KB (gzipped). For such a small difference, is it worth maintaining two version? Thank you for all your hard work :)
@MAddy: they’re not done, but anyway, it’s not only about file size, but also about performance and maintainability.
Cool, been waiting for 2.0 so that I can deploy my Mobile 1.3 app without IE 6/7 nonsense.
Right on, right on.
omg omg omg. Hecks yeah, thanks again guys.
I’m reading my email repeating to myself “I don’t have time for that” and pressing delete. I said to myself, “About the only thing I’d make time for is is jQuery came out with a 2.0 version…”
Please fix the RSS FEED for the JQUERY BLOG.
I’ve been preferring microjs.com stuff (and TJ Holowaychuk’s components) a lot lately because of size and modularity, though jQuery is the only thing that gives you cross-browser peace of mind when doing client work and you just need to deliver. So this 2.0 (and everything new in it) sounds like the right thing at the right time.
Cool! jQuery rocks!
Thank you guys we love jQuery!
we love jquery();
It is so sad for those computers that installed the IE6/7/8.
“Remember that jQuery 2.0 will not run on IE 6, 7, or 8”
Also remember that this is a VERY bad decision. Now is not the time to ditch IE7 and IE8. Ditching IE6 is ok, but IE7 and IE8 are still in use, and customers demand websites to (at least) work on them. Web developers may decide not to have their sites work on IE8, but jQuery must not make this decision for everyone at once.
So, ditching support for the newest IE that runs on Windows XP (which is IE8) is a horrible decision, iyam. And one that will prevent many (if not all) commercial users of jQuery from upgrading to 2.x.
Sorry, this is all I can (and will continue to) say about jQuery 2.0.
Ditch IE6 but support IE7 and IE8, and you will have my respect once more.
@Martijn, please re-read what we have said regarding jQuery 1.9 and 2.0 until you understand that we are not “ditching” anything.
Thanks to every one ..
Yes I read it, using two different versions of jQuery. Welcome to hell. No way I’m doing that.
oh,my god!there are a lot of people with the version of ie9 following in china.
“Don’t feel like you’re missing something or falling behind by using 1.9 on your web site, since the APIs for 1.9 and 2.0 are the same.”
There you go. They are not forcing you to use 2 versions, IE6,7,8 are supported with a fully functional version of jquery. jQuery 2.0 is only for people for whom absence of IE support is not a problem, but higher size / complexity / slowness might be an issue (e.g. WebView in a mobile application).
Also remember that XP is about a year away from being completely out of support too, with Server 2003 to follow in only a year afterwards.
as I read the windows xp in out of support in April 2014, thats a long time to wait.
I think this is great, as long as 1.9, 1.10 in future, are fully supported for some time. It’s convenient to have a specialized 2.0 for something like a mobile site or on a page that uses lots of HTML5 elements – which rules out most older browsers anyway.
IE 10 takes ignores conditional comments, so the code snippet used in the beginning is irrelevant on IE10.
@ Robert McLaws
It does work as published if you try it out. Carefully check the extra comment tags in the gte IE9 section.
Robert’s illustration demonstrate’s exactly this – while conditional comments not applying to IE10+, not exactly the smartest thing to do. If you have IE10 installed, I can imagine it would be very difficult to test working scripts and lte/gte comments.
Too bad “grunt” doesn’t actually work at all:
throw new TypeError(‘Arguments to path.resolve must be strings’);
..seen this for weeks now. Fun times.
I am using 2.0 in my phonegap app and want to go live by early May
What do you guys think? i am going to package 2.0 in my build instead of referring to CDN
Also what is the 2.0 release targeted?
@ernest, I read the reply and am not sure what you’re trying to say. You can safely use 1.9 for all browsers if it seems too hard to decide or understand. We’re not forcing anyone to use 2.0 or conditional comments.
@ernest – with IE10, you can use the F12 developer tools to simulate IE7, 8, and 9 – so that resolves the conditional comments problem, though I understand there are other issues than that one point.