on Articles Resources

jQuery 1.5 Released: What is new?

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon

As they promised, jQuery Team released a new version of jQuery today. It has come a long way from its initial version and has become one of the most used JavaScript frameworks in the world.

I will try to tell you the exciting news in the new version.

As the new version is released, the jQuery Team updated their jQuery 1.5 API Documentation which is very useful and handy.

The biggest news is jQuery.sub() which allows a developer to override native jQuery methods without actually affecting the methods that other users would interact with – or even create encapsulated APIs for your plugins that avoid namespace collision. There are more news like the complete rewrite of the Ajax module, Deferred Objects and many more.

New jQuery AJAX

The jQuery Team rewrote the whole jQuery AJAX module. This rewrite helps to fix a lot of gaps that existed in the old Ajax system along with providing a higher level of consistency across the API.

Perhaps the largest change is that a call to jQuery.ajax (or jQuery.get, jQuery.post, etc.) now returns a jXHR object that provides consistency to the XMLHttpRequest object across platforms (and allows you to perform previously-impossible tasks like aborting JSONP requests).

jQuery AJAX now returns a jXHR Object for backwards compatibility with old XMLHttpRequest

The jQuery XMLHttpRequest (jXHR) object returned by $.ajax(), as of jQuery 1.5, is a superset of the browser’s native XMLHttpRequest object. For example, it contains responseText and responseXML properties, as well as a getResponseHeader() method. When the transport mechanism is something other than XMLHttpRequest (for example, a script tag for a JSONP request) the jXHR object simulates native XHR functionality where possible.

There are three new functionalities for sending, receiving and managing AJAX requests:


A prefilter is a callback function that is called before each request is sent, and prior to any $.ajax() option handling.


A converter is a callback function that is called when a response of a certain dataType is received while another dataType is expected.


A transport is an object that provides two methods, send and abort, that are used internally by $.ajax() to issue requests. A transport is the most advanced way to enhance $.ajax() and should be used only as a last resort when prefilters and converters are insufficient.

Other significant thing is defining Custom Data Types. The jQuery Ajax implementation comes with a set of standard dataTypes, such as text, json, xml, and html. Use the converters option in $.ajaxSetup() to augment or modify the data type conversion strategies used by $.ajax().

Full AJAX documentation is available here.

Deferred Objects

This API allows you to work with return values that may not be immediately present (such as the return result from an asynchronous Ajax request). Additionally it gives you the ability to attach multiple event handlers (something that wasn’t previously possible in the Ajax API).

For example:

        function doSomethingFancy(){
           return $.get('somescript.php');
        function doSomethingMagical(){
           return $.get('magical.php');
        $.when( doSomethingFancy(), doSomethingMagical() )
              // do something when both methods succeed
              // do something when one or both methods fail

This fancy piece of code works because jQuery AJAX now returns an object which contain a promise for tracking the asynchronous request.

To find out more go to Deferred Objects documentation.

Here you can find a comprehensive tutorial on Using Deferreds in jQuery


jQuery Team made this possible to override native jQuery methods without compromising or destroying them and to provide encapsulation and basic namespacing for jQuery plugins.

The best thing to see it on work is this example taken from jQuery site:

(function() {
  var myjQuery = jQuery.sub();

  myjQuery.fn.remove = function() {
    // New functionality: Trigger a remove event

    // Be sure to call the original jQuery remove method
    return jQuery.fn.remove.apply( this, arguments );

  myjQuery(function($) {
    $(".menu").click(function() {

    // A new remove event is now triggered from this copy of jQuery
    $(document).bind("remove", function(e) {

With jQuery.sub() the imagination is your limit. You can extend the framework even further without destroying its core.

This is really a significant release and I hope that developers around the world will use its benefits to build even more responsive applications.

What do you think about new release of jQuery? Express your opinion in comments below.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon

  • Pingback: Tweets that mention jQuery 1.5 Released: What is new? -- Topsy.com()

  • They you for the great synopsis Zvonko. The .sub() addition looks very interesting.

  • Great post, thanks for breaking it down for me 🙂

  • Thanks for your post!
    Small issue, though: there’s a typo. Deffered => Deferred

    • Zvonko

      Thanks, it is fixed now.

  • Pingback: jQuery 1.5: Novedades, Descargas, CDNs y uso en WordPress()

  • Is it fully backward compatible to older releases? Can I replace the old jQuery with the new jQuery 1.5 in my existing projects?

    • Zvonko

      It should be in 99%. The best thing is to try it.

  • raveman

    jQuery.sub() looks kind of scary to me. You have to keep in mind that some developers will abuse it and now when you call any jQuery method you can’t be 100% sure that it works as expected. So I will stay with jQuery 1.4

    • Zvonko

      .sub() is used to override native methods in jQuery. You are not changing anything inside jQuery core, so it will always work as expected.

  • raveman

    is there any way to check if a jQuery method is orginal or AOPed?