On July the 13th, jQuery 3.0 and jQuery Compat 3.0 alpha versions were released. This new major release brings several changes with it and here are the most important ones:
- A new, and quite controversial, behavior for the show/hide methods has been implemented
- The
data()
method has been updated to adhere to the HTML5 dataset specification - jQuery.Deferred is now Promises/A+ compatible
width()
andheight()
don't round the returned values anymore,- Removed deprecated event aliases such as
load
,unload
, anderror
- http://youmightnotneedjquery.com/
- http://blog.garstasio.com/you-dont-need-jquery/
- http://www.sitepoint.com/do-you-really-need-jquery/
var elements = document.querySelectorAll('.parent div');
[].slice.call(elements).forEach(function(element) {
if (element.parentNode) {
element.parentNode.removeChild(element);
}
});
and this is the jQuery version:
$('.parent div').remove();
Which version would you rather prefer to write? And not only you, but what about the other developers in your team? In addition, even with such simple code, here are a few things to ponder:
forEach
isn't supported in IE8 which is still used by many people- The return value of
querySelectorAll
isn't a real Array and as such can't useforEach
- The technique I used to convert an Array-like into an Array (
[].slice.call(elements)
) is quite advanced and unknown to many beginners developers - The code is faster but also longer to write
So, what do you think about this news? Are you and your team still using jQuery? Share what you think with me here or reach me on Twitter.