jQuery 1.4 Released

Tweet

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?

jQuery is probably the most popular JavaScript framework on the web. Many developers insert the script by habit (yes W3C.org, I’m referring to you!), so the jQuery team needs to be extremely cautious when creating new releases.

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: focusin and 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.


$("form").focusin(function(event) {
	alert("event fired!");
});

Useful stuff.

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?

If you’re after a solid JavaScript library, jQuery remains one of the obvious choices. It’s lightweight, functional, and supports the majority of modern browsers. For those upgrading from previous versions, it might be advisable to wait a few weeks to ensure there are no major problems.

Have you tried jQuery 1.4? Comments welcome.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • http://www.lunadesign.org awasson

    Cool…. I’ll have to look into this upgrade. I use JQuery mainly for admin screens on web apps for real AJAX requests but every now and then I have my arm twisted by a client to add some ‘bling’ to a site and JQuery is such a capable library to use I can’t resist it.

  • Global Cooling

    Sounds pretty awesome and focusin will defiantly come in handy

  • Ian Jacobs

    Hello,

    I see in the post “jQuery is probably the most popular JavaScript framework on the web. Many developers insert the script by habit (yes W3C.org, I’m referring to you!), so the jQuery team needs to be extremely cautious when creating new releases.” I work at W3C so I’ve come to ask if there is something we are doing with jquery we should be doing differently.

    Ian Jacobs
    http://www.w3.org/People/Jacobs/

  • php/ajax

    Yes I’ve tried jQuery 1.4 and it’s truly amazing. I love the the new focusin and focusout events

    PHP/Ajax
    http://raxanpdi.com/

  • http://www.optimalworks.net/ Craig Buckler

    Hi Ian,

    Thanks for your comment. As far as I’m aware, you’re using jQuery and a cookie plugin to just handle the desktop/mobile/print widget. Unless you’re planning further functionality, you could implement the same feature in a few lines of JavaScript without any framework. It could also support more browsers (jQuery doesn’t run on older browsers).

    The widget also disappears if JS is disabled. I’d recommend implementing a server-side version and using progressive enhancement. After all, mobile users will find it useful, but not all mobile users have a full JavaScript implementation (especially one that’s jQuery-compatible).

  • http://www.databloc.com/ databloc

    What great improvement! Easy of coding and performance.. It’s Great.

    -Phil
    http://www.databloc.com/

  • http://www.virvo.com Web-Development

    Having married jquery for many of our complex js projects, I dread every jquery update – the testing involved, and the bugs which arise cause major maintenance headache. Ill be waiting for a while before I start updating our scripts.