DEV Community

Mike Ross 🇺🇸
Mike Ross 🇺🇸

Posted on

Why Should I Switch from jQuery to React?

Please help me understand why I should stop using jQuery and switch all my Javascript coding to React. I've been using jQuery for years and have become highly-skilled with it. (I mean, I answer more questions about jQuery on StackOverflow.com then I ask about it, for one thing.)

Top comments (5)

Collapse
 
oleksiyrudenko profile image
Oleksiy Rudenko • Edited

Many ideas from jQuery became part of ES6 (e.g. manipulating/traversing DOM ) or CSS (animations) that are more performant, in theory at least.
React is a different story.
I mean one could replace some of jQuery constructions with native ES6 or CSS3 and still things remain vanilla JS without any frameworks on top of that.
Should you switch? Not necessarily. But you could adopt ES6.

Collapse
 
mikenikles profile image
Mike

Hey Mike (great name by the way ;-)),

I made that change when React was first released. It was good and I learned a ton, released projects and a somewhat popular library. The landscape is changing rapidly though and performance, page load time, and as little JavaScript as possible are the trends I see becoming more relevant.

React doesn't feel like the right choice anymore to me. It's very popular, but a lot of people already know it, hence competition to find a job is high.

I now use Svelte (svelte.dev). It's no way near as popular as React, but I suggest you have a look before you dive all in with React.

If you don't mind me sharing one of my blog posts, I list some reasons why I switched from React to Svelte on my blog: mikenikles.com/blog/why-i-moved-fr...

Let me know what you think.

Collapse
 
tarise profile image
Nikki

At the company I work for, we're in a rut because jQuery is so old and we want to use later technologies. React doesn't seem to be the best option for us because the 2 frameworks clash, so we've been looking into Vue.js. Our experiments with that have failed due to complications with the CMS we're using, which is an old version.

On our end, we've weighed the pros and cons of switching to Vue and React. In the end, we want to switch, but can't at the moment.

I would suggest exploring other technologies, however, without knowing what you're working with, it's hard for me to convince you that you definitely should or shouldn't switch. Are there people saying you should or are you just asking in general?

Collapse
 
ackmandesu profile image
AckmanDESU

In my eyes this comparison is not correct. The use cases for react vs jQuery are very very different. You probably should consider dropping jQuery for vanilla js but that’s it.

99% the time when you’re using jQuery all you’re doing is selecting elements and assigning events. All the compatibility and simplicity it provides is no longer necessary as there’s usually a way for you to do the same with vanilla. The performance gains could be worth it as vanilla is much faster and ofc you’re not downloading 70kb or whatever of extra stuff.

If you like the syntax you could try a light weight alternative to jQuery such as Zepto, umbrella or cash. In some old projects I simply replaced jQuery for one of these and everything kept working without any other changes.

Lastly there’s some less popular frameworks that could provide some of the nice things like reactivity without requiring as big of a change in your coding style or build tools, etc. I don’t know much about this but maybe someone else can chime in for this. You don’t have to go React or go home.

Collapse
 
ackmandesu profile image
AckmanDESU

jQuery takes 1 day to learn if you know JS... It’s not gonna be the next Cobol. If it ever got bad there’d be plenty of people to hire.