Honest Question: What benefits can I hope to achieve by switching from jquery to react?

I’m a freelance coder who builds small-medium apps and my front-end stack primarily consists of Bootstrap+jquery. This combo has never let me down until now even with all kinds of features, functionality and complexity thrown at it. I’ve built dashboards with line charts, puzzles and MCQs, grids and tabular components to edit data, etc. and it was all very seamless.

But when I keep hearing the discussions here and on other places in social media, they make me feel like I’m stuck in a very different century! There is no doubt that React is a well-known, popular and robust piece of software but one thing that dissuades me from getting into it is the whole monstrous npm system of components around it. It seems to be quite integrated with node when it comes to some react components like next, nuxt or whatever. Is it not possible to just like include react through CDN with link or script tags and still make good use of it?

More specifically, I want to know what can I hope to achieve if I migrate from jquery to react? I’m quite tied to the jquery way of doing things right from DOM manipulation to event handling to things like cloning and reusing HTML components in <div> blocks. Is there any established guide or path for folks like us to migrate from jquery and react? And to begin with, is this a good idea even?

Personally I see no advantage in react if you are developing successful with jquery for many years. In fact you will have the disadvantage of performance loss and big overhead on size.

The big frameworks have two advantages why they are used:

For beginners it’s more easy to start as it has already many ready to use modules which are fast to include (just type an import) and they are more type checking and you have a more integrated IDE which makes it easy to do step by step debugging. This all avoids errors when developing.

But I guess here are many others who will not agree with me :slight_smile:

2 Likes

Yup :grin:.

You make valid points, but React and co. have a number of use cases you don’t mention. For example:

  • Component-based architecture
  • Reactivity
  • State management

Components are self-contained, modular pieces of code that represent a part of the user interface. Each component can manage its own state and props, making it easy to reuse them across different parts of an application or even in different projects. Unlike jQuery, where you often end up duplicating code to handle similar UI elements, React’s component-based architecture promotes code reusability and maintainability.

Reactivity refers to the automatic updating of the user interface in response to changes in data. When the state or props of a component change, React’s virtual DOM determines which parts of the actual DOM need to be updated and re-renders only those parts. This eliminates the need for manual DOM manipulation and event handling, which is common in jQuery.

State Management is about how components handle and manage their data internally. Each component can maintain its own state, and when this state changes, React re-renders the component to reflect the new state. This approach contrasts with jQuery, where you need to manually track and update the DOM based on data changes. This makes it easier to build complex, dynamic applications, as it ensures that the UI remains consistent with the current state of the application.

I don’t agree with this. React itself is very performant and getting more so all the time. For example, there is a compiler coming to React, which is a build-time only tool to automatically optimize your React app. We now also have server components, which (as the name suggests) don’t run on the client and thus their code isn’t included in the JavaScript bundle which is shipped.

So that is the question, right? As Thallius says if you have been developing successfully with jQuery for many years, then the benefit of migrating just for the sake of it is questionable.

In my opinion, it depends on what type of applications you are building and choosing the right tool for the job. For example, if you’re building interactive, dynamic applications like single-page applications (SPAs), dashboards, or real-time data visualizations, React is an excellent choice.

On the other hand, if your applications are simpler, primarily involving DOM manipulation and jQuery has been serving your needs well, there’s less reason to switch. Sites with simpler interfaces and less complex interactions, like small business websites or static content pages, will continue to benefit from jQuery’s simplicity and ease of use.

However, this is oversimplifying things…

Frameworks like Next.js and Astro take React further by providing additional features like server-side rendering, static site generation, and improved performance out of the box. These tools cater to developers who want to leverage React’s component-based approach while optimizing for speed and SEO.

Additionally, it’s worth noting that React is highly popular in the job market. Many companies have adopted React for their front-end development, which translates to more job opportunities and better career prospects for developers skilled in React compared to those focused solely on jQuery.

I apologize if this reply has become a bit long and rambling. The reality is that there is a huge ecosystem around React, including numerous libraries, tools, and frameworks, which makes the topic rather convoluted.

Nonetheless, HTH

3 Likes

You see, this is nothing magic. If you develop JavaScript apps since over 15years you normally have developed your own framework which improves from year to year. I have a very simple JavaScript framework which is doing nearly the same and I guess the TO will have also like everyone who is working on one language that long.

So the advantages aren’t that big as you may think.

When I start a new project, I need half a day to setup the main UI with all the things like user management, multi language support etc.
the disadvantage is, that this is not a norm an therefore it’s harder to use for other developers when they overtake the projects as if I would use React or Angular.

Also I do not see any advantage on moving workload to the server. In times where the smallest pads can render and calculate billions of mips, but servers are only virtual servers in virtual server in virtual servers…. In a cloud in a cloud …. With a performance which is horrible for the price you pay :wink:

And sorry, but React might be performant (I absolutely agree that it is faster than Angulat which is the most worse I have ever used) but not in comparison to vanilla JavaScript which at the end is always the fastest IF you are able to write the correct code.

2 Likes

I would also argue that you might want to tackle learning vanilla JS first. It will make you a better developer when you might need to use something like React.

4 Likes