DEV Community

Why do you use jQuery in 2019?

Vinicius Brasil on April 09, 2019

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 t...
Collapse
 
terabytetiger profile image
Tyler V. (he/him)

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:

  • Supporting a legacy codebase
  • Not knowing that vanillaJS has feature {x}
  • Familiarity with JQuery - For example: If you had to choose between looking up how to do something in vanilla or already knowing how to do it in JQuery, which would you choose?
Collapse
 
jjtowle profile image
Jason Towle

Can't argue with the above. Spot on!

Collapse
 
spookylukey profile image
Luke Plant

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?

Collapse
 
ryansmith profile image
Ryan Smith • Edited

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

Collapse
 
niorad profile image
Antonio Radovcic

It still has some advantages. If you do

const a = document.querySelector(`a`)

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.

Collapse
 
jojoshua1 profile image
jojoshua

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.

Collapse
 
eriksk profile image
Erik Skoglund

Bootstrap depends on it.

Collapse
 
ijason profile image
Jason

I second this. Most of my projects depend on Bootstrap

Collapse
 
ironhelixx profile image
Jesse R Davis

Bootstrap is stripping out JQuery in the next version and moving to vanilla JS

Collapse
 
mariocarnival profile image
Mario Vivanco

Well. I am looking how to make a Photo Gallery with coding, and I find some jQuery app for this. I know that I can do with Lightroom, with only CSS also, but which other library more updated can give me a photo gallery component? react? vue? angular?

Collapse
 
garvinc profile image
Garvin • Edited

jQuery is more than just a bunch of features. It is also an opinion on how to do things. For example if you want to hide an element in vanilla JS do you use visibility or display?

For someone who has used jQuery for a long time, pulling in an 80K library and calling $('elm').hide() just makes sense. If jQuery is still supported, they get the performance they need and behavior they expect why should they change it? Wouldn't it make more sense to spend their time focusing on delivering value to their users?

jQuery also has a rich ecosystem of plugins an extensions that would be a pain to reproduce if you decided to migrate everything to vanilla js. Again you have to decide what is the most valuable use of your time.

It is understandable why people get excited about new technology but sometimes we forget why we are doing it. I would be more likely to shift from jQuery to a framework for code organization and maintainability than I would to vanilla js just because I can. The users of your site don't care if you use $() or document.querySelector.

Collapse
 
codestuff2 profile image
Adam Whitlock

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.

Collapse
 
drewknab profile image
Drew Knab • Edited

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.

Collapse
 
iamschulz profile image
Daniel Schulz

We sell most of our projects based on a system that uses jQuery. So yeah, legacy codebase.

Collapse
 
rohovdmytro profile image
Rohov Dmytro • Edited

48.7% of the developers still use jQuery

Years and years of being in dominance.

But I was still surprised by this number in 2019!