DEV Community

Cover image for JavaScript or JQuery? Which do you use?
Uriel Bitton
Uriel Bitton

Posted on

JavaScript or JQuery? Which do you use?

Which one do you use and why?

I find jquery is a lot more convenient for DOM manipulation, however it has the script dependency.

What are the disadvantages or advantages between the two and why?

Latest comments (38)

Collapse
 
seanolad profile image
Sean

Like any smart dev, I use both. JQuery does exactly what it says. It queries stuff, and the stuff being DOM elements. Manipulating DOM is one of the most useful things about JavaScript, but JQuery makes it easy. In my opinion there really aren't any disadvantages to JQuery, if it's used for the problem it's designed to solve then I don't see the problem(get it 😂), otherwise it's like saying that seat belts are crappy because they won't do a thing if you get t-boned by a truck.

Collapse
 
tylerlwsmith profile image
Tyler Smith

I started with a comment, but it got so long that I ended up with a post. jQuery is still super useful.

Collapse
 
urielbitton profile image
Uriel Bitton

haha i love this!
thanks for sharing.

It does seem to be a trend of late to hate on jquery, i dont see the reason why!

Collapse
 
tylerlwsmith profile image
Tyler Smith

Thank you for opening up the conversation. I wish it wasn't a trend to hate on jQuery.

Sometimes I get the sense that people with strong feelings about jQuery may have never worked on projects where it would be a good solution to their day-to-day problems. These days I'm doing a lot of data-driven applications where jQuery would be a bad fit. Maybe if I had only ever worked on apps like this, I'd also struggle to see the value of jQuery.

Thread Thread
 
urielbitton profile image
Uriel Bitton

Right. I work on a lot of client-server side apps and i make tremendous use of jquery, within react. FOr example, handling complex click events and actions and generating html content in apps is super easy in jquery. The same would be much much longer and more complicated in javascript.

Collapse
 
al5ina5 profile image
Sebastian Alsina • Edited

I stopped using jQuery more than a year ago. I use React or Next instead. If I were to build a website without React or Next, I'd guess I'd still use jQuery. jQuery is great, but it's outdated. There's newer and better stuff.

As other have said, everything possible in jQuery is possible in vanilla JavaScript with just a few lines. There's not really a problem with using jQuery, it's just not something that's needed anymore in 2020.

If you're comfortable with the jQuery syntax, go with it! If you can use React or Next, do that!

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

The only when I need jQuery-like API, is Cheerio, which doesn't manipulate DOM, but instead XML, based on htmlparser2.

A problem with jQuery, is it isn't strongly-typed in VSCode (@types/jquery doesn't make it that much better); unlike vanilla JS (and you don't have to install TypeScript or @types/* at all.)

Also, at some time, I have tried cash, an alternative to jQuery and in written in TypeScript. However, DOM tree on web browser, or at least JSDOM in Node.js is required. But mostly, I would say it doesn't help much.

Collapse
 
prahladyeri profile image
Prahlad Yeri • Edited

You are right on spot!

jquery is the perfect library and you are supposed to use it to make DOM manipulation simpler. The few KBs of dependency is nothing considering that megatons of bloatware like angular/react/vue is considered normal and goes unchecked today. Add to the fact that most CDNs typically host all major versions of jquery, the "dependency" is the last thing you need to worry about.

Collapse
 
bartosz profile image
Bartosz Wójcik

JQuery when it's feasible since it's been on the market for so long, some things are just easier in JQuery, although I'm using vanilla JS in some other situations, for example I'm using vanilla JS in my Chrome / Firefox extensions injected into web pages, because it's easier and does the job just fine. I this the hate towards JQuery is a bad thing, I've seen some benchmarks that does like 1 million iterations of simple things, but who does that on a web page? Nobody. JQuery is just a tool, and a pretty good one.

Collapse
 
dmshvetsov profile image
Dmitry Shvetsov

JavaScript (+ optionally lodash).

JQuery is too heavy (big size) and often we are using 1-10% of its functionality. Which [functionality] is almost in 100% cases available in plain JavaScript.

Take a look tobiasahlin.com/blog/move-from-jqu... and youmightnotneedjquery.com/

Collapse
 
annietaylorchen profile image
Annie Taylor Chen

I choose vanilla JavaScript or svelte, the compiler if you want less code. React is easier for job hunting.

Collapse
 
amlana24 profile image
amlan

I use React..

Collapse
 
olton profile image
Serhii Pimenov

Is jQuery not written in vanilla JavaScript? jQuery is syntactic sugar that makes working with the DOM easier. I believe that every JavaScript programmer should write his own jQuery to better understand how the DOM works and how to manipulate it and elements.

Collapse
 
urielbitton profile image
Uriel Bitton

Yes but I mean vanilla js vs jquery