DEV Community

Is JQuery still worth learning in 2021?

Lee on March 27, 2021

With new continued simplicity in ECMAScript or the ease of learning that Vue.js brings, is there even a single use case for JQuery anymore?

Collapse
 
darkain profile image
Vincent Milum Jr

So let's break this down a little.

Firstly, jQuery is more of a library than anything. Libraries essentially extend base functionality of whatever they're added to. So native raw JavaScript DOM + jQuery DOM play extremely nicely with one-another.

Next, React/Vue/etc are all frameworks, and frameworks dictate functionality. They want to force you to use their way of doing things for, well, everything. They don't tend to play nicely with things built outside of their own ecosystem. But these frameworks do have extensive ecosystems at this point.

And what of modern native JavaScript DOM? As others have pointed out, it looks a lot like jQuery anyways. Well, why is that? Probably because jQuery fixed so many features with traditional JavaScript DOM, that JavaScript eventually became modeled after what jQuery did.

Personally, I still use jQuery + jQuery UI for personal projects because of that flexibility to be able to bolt on any other library I need without worrying if its compatible with the ecosystem, since these libraries are all designed to interact nicely with other libraries without dictating what their interaction interfaces need to be.

BUT, if you're looking at the "job market", frameworks have all the hype and buzz, and that's what are asked for on job applications.

Collapse
 
leewynne profile image
Lee

Thanks for this, really useful

Collapse
 
zer0 profile image
zer0

Personal opinion: partially.

It’s good to know how it basically works because there is still a lot of projects/websites out there that use it.
But in general it’s not worth it to learn it primarily. Rather learn it the right reactive way with vue, react, svelte or angular.

Collapse
 
leewynne profile image
Lee

That’s a bloody good point. There is so much JQuery out there.

Collapse
 
moopet profile image
Ben Sinclair

It doesn't matter so much that there's a lot out there. It's pretty evident what a piece of jQuery is doing when you look at it (unlike, say, a bit of react code where you need to understand a lot more concepts and it's frequently written to look "clever", most jQuery is basic DOM manipulation or using plugins. If you drop someone into a legacy jQuery environment, it's also so similar to modern, raw, Javascript that you can drop in a querySelectorAll if you don't understand what the jQuery's trying to do and it'll probably just work.

Thread Thread
 
leewynne profile image
Lee

Make sense!

Collapse
 
taikedz profile image
TaiKedz • Edited

I used to maintain my own hobby website back un the early 2000's before jQuery time. I wrote a "matrix screen flow" and a drag-and-drop lib for a summer job, puzzling out the differences in position calc between browsers. Hell at the time, but simple enough. Then did zero web dev for about 15y.

A couple years ago I had a go at vue.js to make a simple website. I got directed towards its tooling, its weird all-inclusive dev environment and ended up with something that indeed worked - but that was intricately dependent on vue.js runtime processes. Not something I could just add to an existing page. A previous commenter here pointed out how frameworks don't play well with anything other than themselves. If you find a limitation in the framework relative to what you want to achieve, you jump through hoops of restrictions imposed by a framework that has its own opinion, heedless of your needs.

Simply put, unless you greenfield your project to a framework, and marry to it, you're f/cked for any other type of web development.

So I am pretty much of the opinion nowadays that if you have to learn a framework for a specific project, you need to do it, but the real question is, why would you tie yourself up like that? On the contrary, try to not rely on framework idiosyncracies. If it can't play well with existing systems, is it worth betting reliability on, for the long term?

Collapse
 
stojakovic99 profile image
Nikola Stojaković

The sole reason frameworks exist is to make your life easier by providing functionalities you need out of the box. It would be too much to always write everything from the scratch.

Also, choosing framework mostly comes from the personal preference. I typically choose React because I'm most familiar with it and I know it's ecosystem very well. I never came into the situation where I thought damn, I wish I didn't chose React but X or did this without any library and I worked on both, small and huge projects.

In very rare cases where you have multiple frameworks on the front-end or need to incorporate them you can implement microfrontends.

Collapse
 
taikedz profile image
TaiKedz

Indeed. Frameworks, libraries, and many other applications and tools, are designed to make a task easier.

My point is, if the framework in question and its own ecosystem have a tendency to force you into doing things One Holy Way, at the exclusion of the rest of the ecosystem, it's definitely worth stepping back and thinking, "Why?"

Thread Thread
 
stojakovic99 profile image
Nikola Stojaković • Edited

Because of the reason I mentioned in the first point - writing everything from scratch would take too much time and it will lead to unnecessary repetition.

If someone already wrote a library for making HTTP requests, it's properly tested and it's stable, why would you write your own library? Just to be able to say that you're not forced to do things in a certain way?

Collapse
 
leewynne profile image
Lee

Enjoyed reading that 😎

Collapse
 
khangnd profile image
Khang

The main focus should still be the fundamentals, which is JS DOM in this case. If you've got yourself familiar with all these getElementById, getElementsByTagName, querySelector, querySelectorAll, etc. then when you have to work in a project that uses jQuery, you will adapt quick and easily.

Collapse
 
leewynne profile image
Lee

Nice, makes sense thanks 😊

Collapse
 
mohdahmad1 profile image
Mohd Ahmad

I would prefer ES6 over JQuery, cuz jQuery is old and why add 180kb to your build size when ES6 provides all features jQuery does?

Collapse
 
nicozerpa profile image
Nico Zerpa (he/him)

That's a very interesting topic! I think I'm going to write an article about it later today.

It's good to know jQuery and there are still use cases for it. However, I don't think you should spend a lot of time learning it.

Nowadays, the biggest advantage of jQuery is that you can manipulate the DOM with less code. The DOM is fantastic, but it's quite verbose. With jQuery, you can do the same things in simpler ways.

Yes, now the DOM has new features to make things easier, like document.querySelector or fetch. But there are still quite a few tasks that require a lot of code if you want to go vanilla.

The thing is, if you are working on a small project, it's not worth adding an extra library. And if you have a big project with lots of DOM modifications, you'll probably need a UI framework like React, Vue.js, and friends.

If you do complex tasks and do the DOM changes yourself (either with jQuery or using vanilla JS), it can easily lead to unmaintainable code.

The big advantage of modern UI frameworks is that the framework itself takes the responsibility of changing the DOM, so you can focus on the business logic and declare how it should be displayed on the page.

Also, jQuery isn't hard to learn. If one day you have to work on a project that uses it, you can learn the library on the go. That's how I learned it 10 years ago! Just google a cheat sheet and you'll be fine.

Personally, I work on projects that use jQuery, but I no longer use it for new projects.

Collapse
 
leewynne profile image
Lee

Thanks, nice to hear the business concepts and frameworks and how they are important with constant collaboration at scale

Collapse
 
miketalbot profile image
Mike Talbot ⭐

jQuery is a key part of writing tests in Cypress so I pretty much use it every day for that - the selectors are powerful and go further than the built-in ones. I do avoid it in production code these days.

Collapse
 
leewynne profile image
Lee

Well I didn’t know that. TIL!

Collapse
 
dustinxavier profile image
Dustin Dinh • Edited

I open to check the technologies, frameworks of a website/web app when I came and yes, there is a lot of websites still using jQuery as a library for their site, and most of those websites were built on MVC. What I mean is if you want to build a website with an MVC paradigm, jQuery is a good choice if you don't have any experience with JS or ECMAScript. But if you want to build a SPA app, you probably shouldn't/no need to use jQuery. VueJS, ReactJS, Svelte give you everything that you want. (Sorry for my bad English)

Collapse
 
stevexm profile image
Steve Melnikoff • Edited

ExtJS -> JQuery -> React -> Web components; technology never sleeps. Developers like John Ressig (JQuery) pioneer the way, then eventually, the slower language standards committees and browser engineers incorporate the “best of” features. Just one example, ES6 modules. For myself, to really master React I first learned, and used jQuery. We all stand on the shoulders of giants, ‘nuff said 🖖

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

In order to make use of jQuery plugins, or sometimes Javascript libraries targeting no build step.

Collapse
 
leewynne profile image
Lee

I didn’t know JQuery UI was even a thing 🙈