What’s New in jQuery 1.4.3

The third minor release of jQuery 1.4 is available now. The popular JavaScript library has received a number of additional methods, bug fixes and speed improvements — here are the new features which caught my eye…

jQuery.type

Determining type can be tricky in JavaScript. Everything is an object so you need to be especially careful with the standard typeof function. jQuery.type will make life much easier for developers…


$.type(true) === "boolean"
$.type(3) === "number"
$.type("test") === "string"
$.type(function(){}) === "function"
$.type([]) === "array"
$.type(new Date()) === "date"
$.type(/test/) === "regexp"

HTML5 data attributes

jQuery now supports HTML5 data attributes, e.g.


<div id="info" data-site="SitePoint" data-registered="true" data-options="{'name':'user'}" />

jQuery converts values to their native JavaScript type so data can be accessed and updated, e.g.


$("#info").data("site") === "SitePoint";
$("#info").data("registered") === true;
$("#info").data("options").name === "user";

Ajax

jQuery.support.ajax is a new property which returns true in browsers which support XMLHttpRequest. This is rarely a problem on the desktop, but XHR availability is more patchy on mobile devices.

The jQuery.readyWait property has also been added. This delays execution of the ready event so you can load dependencies or perform other actions before it’s fired.

Events

It’s now possible to prevent the default action and bubbling on any element using:


$("a#link").bind("click", false);

Similarly, .unbind("click", false) will remove the action.

Animation and effects

The new jQuery.fx.interval property sets or gets the animation frame rate. The default is 13 milliseconds but it’s possible to reduce that value for smoother animations (assuming your browser is able to keep up).

DOM traversal

jQuery makes greater use of the native querySelectorAll and matchesSelector methods when they’re available. Some functions are now 8x faster than version 1.4.2.

CSS module

The CSS module has been rewritten so it’s possible to write custom plugins which extend .css() and .animate().

Links

Grab jQuery 1.4.3 from:

Impressively, jQuery maintains good backward compatibility. The core API is stable and unlikely to break your existing applications. John Resig’s team keep polishing their code to make it faster, leaner and more flexible.

News just in …

jQuery Mobile 1.0 Alpha 1 has been released! Keep reading SitePoint for more information soon…

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.

  • Helping…

    dude..jquery mini is 76kb..hope u r not putting the distant dream…cheers

  • Addy

    Umm.. jQuery min for 1.4.3 is actually only 26KB. Not sure what version you’re using.

  • aemciv

    the min file downloaded shows 76kb

  • http://logicearth.wordpress.com logic_earth

    To get to 26KB you have to send jQuery with gzip compression. Without it, it is 76KB. All the CDN that provide jQuery do use gzip and you should probably be using the CDN anyways.

  • lazukars

    Contrary to popular belief, and what this article states, everything in javascript is NOT an object.

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

      For example…?

    • darkwater23

      Called out by the author! LOL Let’s see a link!

    • Schepp

      lazkars is right but at the same a little overpicky on that matter: http://javascript.crockford.com/survey.html

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

      Even primitive data types (boolean, number, and string) are objects, e.g.

      var s = new String(“my string”);

      You can even use the prototypal inheritance chain to add properties or methods to that object instance, e.g.

      s.constructor.prototype.p1= “my new property”;
      alert(s);
      alert(s.p1);

      null and undefined are non-object data types. But they’re used to denote that you don’t have an object — you couldn’t use an object to represent that!

      • kissmyawesome

        Well, there is a difference between primitive data types and objects..

        var a=true;
        var b=new Boolean(true);
        a==b; // true
        a==true; // true
        a===b; // false

        When testing a==b, if both were truly first-class objects such as Arrays, this would evaluate to false.

        var a=[];
        var b=new Array();
        a==b; // false

        The difference is that primitive data types are treated *like* first-class Objects when needed. So they are technically different, even if not in practise.

  • lazukars

    From ‘JavaScript the Definitive Guide':

    “The truth is that a corresponding object class is defined for each of the three key primitive datatypes. That is, besides supporting the Number, String, Boolean datatypes, JavaScript also supports Number, String and Boolean classes. These classes are wrappers around the primitive data types”