jQuery is one of the world’s popular JavaScript library. It has been considered as a blessing for a plethora of web developers nowadays. It was first released in 2006, and a plenty of web developers have put jQuery to use in their projects. Recently, jQuery has announced the first alpha of jQuery 3.0.
You can get a comprehensive list of jQuery Interview Questions here.
Let’s take a look at what’s new in jQuery and how you can use it.
It is a slimmer and faster version of jQuery. In this new version of jQuery, old IE has been removed and taken advantage of the modern web APIs. It is a continuation of the 2.x branch but of course with some significant changes. jQuery 3.0 is considered as the future of jQuery.
If you need IE6-8 support, you can continue to use the latest 1.12 release.
Here are significant changes in jQuery 3.0 version.
Slim build
It is a new thing added in this 3.0 version of jQuery. It is simple to use the combination of CSS and class manipulation for all your web animations. Apart from the regular jQuery version, which includes the Ajax and modules, a slim version has been excluded in these modules. All in all, it excludes ajax, effects, and currently deprecated code. The new slim build is about 6k gzipped bytes smaller than the regular version – 23.6k vs. 30k.
Compatibility with jQuery UI and jQuery Mobile
With the new release, few issues jQuery UI, and jQuery Mobile has been addressed. On finding any issue, it should be addressed upstreaming by using the jQuery Migrate 3.0 plugin.
Other Major Changes
jQuery.Deferred Promises A+ compatibility
The jQuery.Deferred objects have been updated for compatibility with Promises A+ and ES2015 Promises, which is further verified with the Promises/A+ Compliance Test Suite. Legacy behaviour can be altered by replacing any use of .then() with the now-deprecated .pipe() method.
Added .catch() to Deferreds
The catch() method was added to promise objects as an alias for .then(null, fn).
Error cases don’t silently fail
In the previous version, jQuery tried to make cases rather than committing mistakes. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 } With jQuery 3.0, such cases will throw errors so that unreasonable requests cannot be ignored. You can try out to see if there is any code depending on jQuery to mask problems with invalid inputs.
Removal of deprecated event aliases
There is no more use of .load, .unload, and .error, deprecated since jQuery 1.8, is dead. Use .on() to register listeners.
Animations Use: requestAnimationFrame
jQuery will now use the requestAnimationFrame API when performing animations. This should result in animations that are smoother and use less CPU time and preserves battery as well on mobile devices. Although this requestAnimationFrame was practised earlier also, there were serious compatibility issues with existing code so we had to back it out. If we think we’ve beaten most of these matters by suspending animations while a browser tab is out of view. But still, if any code relies on animation, it is better to run it in real time.
Massive speedups for some custom jQuery selectors
Here extra efforts have been skipped when custom selectors like: visible are put into use. By this improvement, selectors like visible and: hidden can be expensive because they depend on the browser to determine whether elements are displaying on the page. While we never discourage to make use if it, we recommended testing your pages to determine if these selectors are causing performance issues.
Although the changes were made into 1.12/2.2, we wanted to reiterate it for jQuery 3.0.
I hope you like the write-up where we have discussed the notable changes in jQuery 3.0 version. Please leave a comment below, if you want to discuss anything more about jQuery 3.0.
Author Bio:
Sophia is a renowned WordPress developer by profession and likes to share here experience through blogging. She can be a great resource for those who are looking to hire WordPress developer in USA, then you can get in touch with her.