JavaScript has matured a lot in the last years, and IMHO, jQuery has become irrelevant for me.
But that's not a reality for every developer, as the Stack Overflow Developer Survey Results 2019 has shown that 48.7% of the developers still use jQuery.
With a much easier and mature JavaScript, why do you use jQuery? What are the uses that vanilla JS can't do easily?
Oldest comments (18)
I have no evidence to back this up, but I'd be willing to guess that it's not about what jQuery does that vanilla can't do easily, so much as one of the following:
Can't argue with the above. Spot on!
It is in place in a legacy app, but I have been trying to use more standard JavaScript. I came across this GitHub repo with some good examples to help in going from jQuery to standard JavaScript github.com/nefe/You-Dont-Need-jQuery
It still has some advantages. If you do
And then try to use a, it will throw an exception. With jQuery it just fails silently. This can be a pro or a con depending on your use case.
Also a good thing to use it for is when you receive a bunch of HTML in a string from a server and want to insert it into your document.
We sell most of our projects based on a system that uses jQuery. So yeah, legacy codebase.
There are still quite a lot of things that jQuery provides that are not one-liners in Vanilla JS. For example - serialize, and event delegation with on. And then dozens of other bug fixes and conveniences.
Of course, you can implement these things yourself in Javascript, but why should you do that? Are you sure that copy-pasted code you found on the internet really works correctly on all browsers, or was it an 80% solution that got lots of upvotes on StackOverflow by people that didn't test it very thoroughly? Do you want to have to learn a hundred different browser gotchas the hard way, and is that really a good use of your time?
I would say legacy codebases. Mostly WordPress themes with jQuery libraries. I still enjoy using jQuery for quick fixes and getting stuff done easily. If it is already in a project, then I see no reason not to use it. Otherwise if I can I will use just vanilla and Vue.
Bootstrap depends on it.
I second this. Most of my projects depend on Bootstrap
Bootstrap is stripping out JQuery in the next version and moving to vanilla JS
Years and years of being in dominance.
But I was still surprised by this number in 2019!
Legacy codebase. The library is still loaded up on every page. May as well use it, and mixing up querySelectorAll() and $() in the same application sounds like a recipe for disaster.
It's just not a priority to do massive rewrites just to expunge jQuery. If I started a project from scratch today, no, I wouldn't use it.
I use jQuery because it is a library that performs very well and helps me do things in a pragmatic way. No doubt that JavaScript has gotten better but there are things that can be done via jQuery which are more elegant and easier to maintain. You write and application once and maintain it forever. There is nothing wrong with jQuery in 2019 or beyond. Web developers use dozens of libraries to make their lives easier. jQuery is no different in this regard.
It's fine if you can or want to write applications without jQuery but don't expect a gold star just because you didn't.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.