It’s been some time coming, but jQuery 1.4 was released last week. Note that it’s not yet available from the main jQuery website, but you can find it at jquery14.com. Here are the main links if you’re eager to get your hands on it:
What’s New in jQuery 1.4?
The code base has been heavily restructured to reduce complexity and increase performance. There are some impressive bar charts on jquery14.com which highlight how good the optimizations are.
207 bugs have been fixed and the framework now passes 100% of all tests in IE6, IE7, IE8, Firefox 2, Firefox 3, Firefox 3.5, Safari 3.2, Safari 4, Opera 10.10, and Chrome.
There is a substantial number of new methods and two new events:
focusout. These are equivalent to focus and blur, but they implement an event bubbling-like technique (focus and blur do not normally bubble). For example, you can attach a handler to all your forms which is fired when any of the internal controls receive focus, e.g.
What Will Break If You Upgrade?
The jQuery team has provided a list of the most likely problems. I suspect the following issues will cause the most confusion:
1. jQuery() returns an empty set
In previous versions of the library, running
jQuery() (no arguments) returned
jQuery(document). It now returns an empty set, although the
jQuery().ready() event will still fire as expected.
2. Ajax requests must use valid JSON
If you’re passing JSON data in Ajax calls, you must ensure it’s not malformed.jQuery now use the browser’s native
JSON.parser in preference to
eval when possible.
3. jQuery.browser returns the engine version
If you’re sniffing for browsers, jQuery.browser now returns the rendering engine version rather than a specific browser type, e.g. “webkit” rather than “chrome”.
I mentioned how difficult user agent parsing had become in a previous post. The jQuery developers have reduced complexity and increased speed by simplifying the returned information.
Although jQuery still supports browser-like detection, I strongly recommend you avoid it and use feature/object detection instead.
Is jQuery 1.4 For You?
Have you tried jQuery 1.4? Comments welcome.