JavaScript - - By Craig Buckler

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…

Sponsors
Login or Create Account to Comment
Login Create Account