jQuery 3.0
Is there a necessity to talk much about jQuery? I mean, come on, everybody knows it. It’s a library that focuses on the interaction between HTML and JavaScript and helps to get access to the DOM elements and manipulate them. Many other libraries were developed based on jQuery.
The state of the jQuery library at the time of writing this is version 3.0 Release Candidate. Let’s check the list of updates.
jQuery 3.0 Release Candidate Features
First of all, jQuery 3.0 will become the only and main version of the library. The 1.12 and 2.2 branches won’t get new features. The new version of jQuery won’t support IE6-8. You should use version 1.12 if IE6-8 support is crucial for you. To avoid problems, better check 3.0 Upgrade Guide.
jQuery.Deferred objects have been updated for compatibility with Promises/A+ and ES2015 Promises resulting in changes of the .then() method:
- An exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution and irreversibly locking both the parent and child Deferred objects.
- The resolution state of a Deferred created by .then() is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfillment values. Previously, returns from rejection handlers became rejection values.
- Callbacks are always invoked asynchronously. Previously, they would be called immediately upon binding or resolution, whichever came last.
You can always recover the behavior of the then(), method from the previous versions of jQuery by using the .pipe() method which is deprecated in the third version.
jQuery Deferred Reporter Plugin is a new plugin that was built to help in debugging Promises/A+ compatible Deferreds.
The catch() method was added to promise objects as an alias for .then(null, fn).
Event aliases .load, .unload, and .error were removed from the library. Instead of using them, you should register new listeners using .on().
Now, jQuery uses requestAnimationFrame API, which should lead to smoother animation with less CPU usage. This feature will be extremely important for mobile applications because it will help to save battery power.
Speedups for some custom jQuery selectors were achieved. Developers have identified the way to eliminate the amount of produced work when custom selectors like :visible are used many times in the same document. That particular case is up to seventeen times faster now. Despite this news, you should remember that selectors like :visible and :hidden still can be expensive.