BT

Long-awaited jQuery 3.0 Brings Slim Build

| by James Chesters Follow 2 Followers on Jun 15, 2016. Estimated reading time: 2 minutes |

The jQuery team has unveiled the long-awaited 3.0 release, bringing a new slimmed-down option as well as major new features, improvements, and bug fixes.

In the blog post jQuery 3.0 Final Released! Timmy Willison, jQuery core team member, announced the "slim build" of jQuery saying "Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations."

Alongside the standard jQuery, the slim version excludes ajax, effects, and currently deprecated code, coming in at a svelte 23.6k vs the full version's 30k. The slim jQuery package can be downloaded here.

Among the new features in the 3.0 major milestone, anticipated since October 2014, is an updated jQuery.Deferred objects. Now compatible with Promises/A+ and ES2015 Promises, Willison explains that in 3.0 "an exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution. Any deferreds relying on the resolution of the deferred that threw an exception would never have resolved."

Willison also makes the important distinction that it is more declarative to handle caught exceptions with rejection callbacks, placing on developers the responsibility to always add at least one rejection callback when working with promises.

Further improvements in the 3.0 release include the use of the requestAnimationFrame API when performing animations, promising smoother animations and reducing the drain on battery power for mobile devices. While Willison notes that this update was previously attempted and abandoned after code compatibility issues, he says the team are hopeful this has been resolved by suspending animations while a browser tab is out of view.

In addition to a raft of other changes, jQuery 3.0 now brings formal support for jQuery.ready promise. While it is noted that jQuery.ready has been consumable as a promise-like object since jQuery 1.8, the object is documented as supported via jQuery.when or the native Promise.resolve(). An example for typical usage is provided:

$.when( $.ready, $.getScript("optional.js") ).then(function() {
   // the document is ready and optional.js has loaded/run
}).catch( function() {
   // an error occurred
})

The release also comes with some breaking changes, despite attempting to be as backwards-compatible as possible. In jQuery core, jQuery is being built with the "use strict" directive, although it is noted that most existing code should not require any changes because it is not required to run in Strict Mode.

Other breaking changes include the removal of the deprecated .context and .selector properties in jQuery core, as well as a change to data names. From 3.0, all data names are stored in camelCase (clickCount), rather than kebab-case (click-count).

For more information on what's new in 3.0 and breaking changes, developers should see the jQuery Core 3.0 Upgrade Guide.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT