Why is it so bad to use jQuery?

Hi all!

Based on various readings and some job descriptions I have seen, I understood that jQuery does not seem to be very much appreciated in the web dev world. What’s the reason ?

I thought jQuery can be very handy sometimes. I’m not sure how I would handle mouse/keyboard events, or AJAX requests without jQuery.

As a side note, I have tried to use jQuery with my Node/Express API project, and it seems pretty complicated. It seems there is little support in Node to do that. I decided I would make a React component instead, to do what I wanted to do with jQuery.

JQuery is a mainstream technology and one that you need to know. It can be very useful.

Some people don’t think it should be used if all you do with it is use the convenience of its selectors. If that is all you do then perhaps it adds too much overhead to your web app to justify using it. But if it is an integral part of your coding, my opinion is to go ahead and use it.

I think that the main reason that jQuery is looked down on (based on several blogs I’ve read) is because its so “hacky”. You’re manipulating the DOM directly, which is comparably slow.

jQuery also has no support for variable interpolation (you need to directly modify the contents of DOM elements, rather than the contents of the DOM being bound to variables in your JS code). This makes it hard to use jQuery for data-driven applications where you just want to change, for example, one word in a sentence. With jQuery you need to modify the entire contents of the tag containing that sentence. With, for example, Angular you could just change a variable in your JS and the HTML would automatically be updated.

It’s also very difficult to write a segment of HTML that can be reused over and over again. This can make your code very repetitive and thus, brittle.

Having said all that, jQuery really is a fantastic library for small scale applications/sites. If you are making something small, then including a large library could really cause a lot of overhead in your application, for absolutely no reason.

For your side note, there are two ways (that I’ve found, I’m only new to Node though) to work with jQuery. One is to create a static path that points to your node_modules folder and then required files will be served from there (I have no idea if this is best practice, but I felt uncomfortable exposing all of the modules for the sake of two or three client side libraries) or to copy the scripts that you need into your public directory, using a build script. That way they will get served alongside the rest of your static, client-side assets. If you’re interested, I actually just wrote a build script to do exactly that last night. It would have been easier to use Gulp or some other task runner, but I wanted to see if I could do it in pure JS.



1 Like

Who dares to not like jQuery? Bring the non-believers to me!

How were you planning to use jQuery in Node? jQuery doesn’t work outside of the browser.