jQuery 3.0—Out Now!

DZone 's Guide to

jQuery 3.0—Out Now!

Web developers rejoice! The latest version of jQuery just released with new features, fixed bugs, and plenty of support for a smooth upgrade. Read on for the fly-over view of what's new in jQuery 3.0.

· Web Dev Zone ·
Free Resource

It's been a long time coming—since October 2014, to be precise—but finally, the new jQuery 3.0 has officially arrived. With new features, a slim version, and a focus on backwards compatibility, the latest version of the most popular JavaScript library is getting lots of love from the community.

Image title

Ease Those Upgrade Pains

Although there's plenty of support for helping with the upgrade, as with most major version updates, there are some breaking changes that could potentially affect existing code, though the team has said, "Most of the time the impacts are only for specific edge cases as noted." Using the jQuery Migrate 3.0 plugin, devs are offered specific advice about most of the major changes that may affect their code. Be sure to check out the JQMIGRATE 1.x warning documentation as a reference point for understanding these messages to better identify and fix compatibility issues.

For those using older versions of jQuery, as the team notes:

"With all the years of accumulated changes, it isn’t possible to have a single version of jQuery Migrate that can support all the changes from jQuery 1.6 (five years ago!) all the way to jQuery 3.0. So, with Migrate 3.0 we recommend this process [scroll down to the section with the bullet points] to upgrade to jQuery 3.0."

And, if you uncover any problems along the way, they urge you to report these migration issues on GitHub.

So, What's New?

The major theme of this release seems to be slimming down and speeding up. As such, the team has cut the various old IE workarounds and utilized some of the more modern web APIs where possible. 

Say Goodbye to the Old IE

If you still need IE 6-8 support, you can continue to use the latest 1.12 release as it will continue to get critical support patches. However, version 3.0 is looking ahead, choosing to cut the bulky workarounds in favor of a lighter design.

Browsers that will be supported include:

  • IE (9+)
  • The current and coming versions of Chrome, Safari, Edge, Firefox, and Opera
  • Safari Mobile iOS (7+) and Android (4.0+)

Slim Version

If you have a preference toward standalone libraries that focus on ajax requests or simply don't need it, you're in luck as there's a slim build available. This version also excludes the effects modules and currently deprecated code. This will cut a little over 6k gzipped bytes from the total size, bringing it down from 30k to 23.6k.

New and Noteworthy Features

To get a detailed list of the new features added, it's best to check here. Likewise, if you want to know the various issues that have been fixed, you can take a look at the GitHub bug tracker.

Below are some of the major new changes at a glance:

  • jQuery.Deferred objects are updated for compatibility with Promises/A+ and ES2015 Promises. (Having troubles with Deferreds? Luckily there's a plugin to help in debugging Promises/A+ compatible Deferreds in case you aren't given enough information about an error on the console to determine its source.)

  • No more silently failing error cases. Now, if a "crazy request" is made an error will be thrown. Check out the example given by the jQuery team:

"Perhaps in a profound moment you’ve wondered, “What is the offset of a window?” Then you probably realized that is a crazy question—how can a window even have an offset?

In the past, jQuery has sometimes tried to make cases like this return something rather than having them throw errors. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 }."

This is no longer the case... now, an actual error will be served.

  • Deprecated event aliases are no more. Since jQuery 1.8, .load.unload, and .error have been deprecated—and now, they've been removed. You should use .on() to register listeners.

  • Many jQuery custom selectors are much faster. Customer selectors like :visible and :hidden have been greatly improved, though are still performance-expensive because they depend on the browser to determine whether elements are actually displaying on the page.

These are just a handful of the major updates. The requestAnimationFrame API is now available to jQuery (having failed in the past), the catch() method was added to deferreds, and much more!

That's All Folks

I know that many of you are probably ready to go and get started, while others might be a little more curious about what the community has to say. Let us know your opinions about this new release in the comments. 

javascript, jquery, jquery 3.0, library, release, web development

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}