jQuery 3 alpha has been released. More "You don't need jQuery" websites coming?

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() and height() don't round the returned values anymore,
  • Removed deprecated event aliases such as load, unload, and error
As a member of the team, I'm really excited about this news as it's been a while since a new major version of jQuery wasn't released. I'm also really eager to hear what developers around the world think about it. I'm also waiting to read posts about a topic that comes back every now and then: is jQuery still relevant? Many developers feel that because browsers are now more consistent with each other and they adhere more to web standards, the need for jQuery is decreasing. Some examples of websites or posts sharing this sentiment are listed below: While the previous two points are true, jQuery still hides many issues through its API. Moreover, I feel that most native methods lack important features. For example, what about selecting a set of elements and deleting them from the DOM? Here's how you do it in raw JavaScript:
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 use forEach
  • 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
From these points you can probably understand some of the reasons why jQuery is the most used JavaScript library in the world. One day, it'll be definitely abandoned in favor of native methods but I think we're not there yet. Anyway, jQuery will remain the most disruptive and important library ever of the history of JavaScript (at least according to me).

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.

2 Likes

So instead of hiding the element then using show(), the advice is to instead apply a classname of “hidden” and remove that classname when you want to show something.

That’s a technique that is commonly used which I fully agree with, but an interesting side-effect of this advice is that it results in show and hide not being used any more for that type of situation.

I would like to see more examples of common use-case situations of how show/hide are recommended to be properly used for those situations.

Separately, I’m not sure of the appropriateness of the removing multiple elements example, for in my personal experience my first hand doesn’t run out of fingers for when I’ve had to do such things. It has me wanting to find a different more relevant example of code instead.

I love controversy; what is the issue? What’s the new show/hide?

It’s easy enough to cut and paste, and then you don’t have a whole library to download just to do something simple—if that’s all you need to do. :slight_smile:

Of course, you usually have more things to do, but still, it is fun to find out how to do things without a library working behind the scenes.

Currently show/hide is a complex process due to large amounts of additional situations being catered for. They’re being simplified in version 3 so that they pretty much only affect the display;none aspect of things, without the other fancy stuff that they did.

1 Like

Woop V3 still going strong. I love JQuery and will no doubt be one of the last few to stop using it. At the cost of an 35kb (if you don’t account for the fact thats it’s probs cached through a CDN) the overhead is so small that it’s almost worth adding for the sake of adding. I always laugh when you have it’s size questioned only to replaced by a full out MVC framework.

and rapidly getting smaller as the various commands are being reduced to simple wrappers around the corresponding JavaScript statements.

A world without jQuery?

Heresy!

:smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.