435-jquery-143

What’s New in jQuery 1.4.3

By | | JavaScript

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…

The Ultimate JavaScript Bundle: 2 books + 1 course

Buy now $39 Normally $117 - save 66%

Or get access to all SitePoint's Premium Content with a Learnable membership

Craig Buckler

Craig is a Director of OptimalWorks, a UK consultancy dedicated to building award-winning websites implementing standards, accessibility, SEO, and best-practice techniques.

More Posts - Website

{ 11 comments }

lazukars October 22, 2010 at 5:06 am

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”

lazukars October 19, 2010 at 12:47 pm

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

Craig Buckler October 19, 2010 at 8:10 pm

For example…?

darkwater23 October 20, 2010 at 1:24 am

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

Schepp October 20, 2010 at 5:55 pm

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

Craig Buckler October 20, 2010 at 6:15 pm

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 October 22, 2010 at 1:35 am

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.

logic_earth October 19, 2010 at 5:29 am

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.

aemciv October 19, 2010 at 4:10 am

the min file downloaded shows 76kb

Addy October 19, 2010 at 2:09 am

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

Helping... October 18, 2010 at 9:46 pm

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

Comments on this entry are closed.