DEV Community

Yahaya Oyinkansola
Yahaya Oyinkansola

Posted on

A Comparison between ReactJS and jQuery

Hi, welcome back to my blog, today I would like to compare two front end technologies developers use to build websites and web applications, React and jQuery. I am also currently learning TypeScript, and I am writing an article about how I used TypeScript to recreate a FEM project I built with JS, expect to see that soon.

Introduction

ReactJS and jQuery are both popular front end tools for developing websites and web applications, but they have different purposes and excel in different scenarios. It's important to understand their differences and use cases so that you as a developer can choose the right tool for your projects. First of all, I know you will be like, what's even the point of learning jQuery in 2024?, before you attack me, you should know that as of August 2022, 77% of the 10 million most popular websites still use jQuery, source from Wikipedia. I think that says a lot about how jQuery is still very important in the web ecosystem, so it isn't going away anytime soon.

What is ReactJS?

ReactJS is JavaScript library used to build complex user interfaces. It follows a component-based architecture that allows developers create reusable UI components. React has a large community with widespread corporate backing, which makes it an ideal choice for many large-scale applications. Here are some of the key features React provides

Component-Based Architecture:
In React, your entire UI is made up of components. Take for example your twitter feed, you have the like component, the tweet component that shows a users tweet, the retweet component, the trending component etc. With React, you can deal with this components individually, and combine them together to form your entire UI which promotes reusability and modularity.

State Management
With React, you don't have to directly manipulate your DOM like how it is done in jQuery with things like $("#test").text(""). React uses what is called a state. Whenever you update the state of a component, React essentially reacts to that change, and re-renders the component to reflect the change

Virtual DOM:
This is the feature that makes react stand out from libraries like jQuery. The Virtual DOM is a lightweight representation of the real DOM in memory. Whenever the state of your component updates, React uses it's diffing algorithm to figure out what has changed in the Virtual DOM, which in turn updates the real DOM. This helps to efficiently update and render only the necessary parts of your components

JSX
React uses a syntax known as JSX that allows you write HTML within your Javascript code with ease, no need for complex string interpolation. Although, developers who use other frameworks like Vue and Angular don't really like JSX that much, but I feel it's not so bad. Let me know what you think

Currently, I am in an internship called HNG Internship, and they also use React as part of their Tech Stack. This internship has produced industry proven developers, so if you are looking for professional developers, check out their hiring platform on their website. I am looking forward to learning more about React from this Internship, as well as make more friends and expand my network.

One thing to understand about React is that React is just the "View" in the MVC architecture. It isn't a full fledged framework like Angular, it's only responsibility is to render the view of your application, and ensure the view is in sync with the state.

What is jQuery?
jQuery is a lightweight, fast, and feature-rich JavaScript library. It simplifies HTML DOM manipulation, event handling, and animation, making it easier to use JavaScript. I got to enjoy writing JavaScript code more because of jQuery, it simplifies so many things that pure JS sometimes can overcomplicate. Some features that jQuery provides are :-

  • Simplifying DOM manipulation. This isn't so straight forward with React

  • It provides support for AJAX (Asynchronous JavaScript and XML). You might argue most recent codebases don't use AJAX anymore, but there are still a lot of websites out there that use jQuery, and they need AJAX in other to do asynchronous operations

  • Cross browser compatibility - jQuery ensures that code works across multiple browsers, without any errors

  • It is useful for running simple scripts like form validation, simple animations like slide up, show and hide etc.

Key Differences

The key differences between React and jQuery is in the area of DOM manipulation. React uses a Virtual DOM, it doesn't manipulate the DOM directly, rather it only updates part of the DOM that changed, while with jQuery, you directly manipulate the DOM. React also offers better performance than jQuery thanks to how it handles DOM updates compared to jQuery's direct DOM manipulation. Since you can break your UI into several components with React, building complex applications becomes easier than if you were to try it with jQuery

Conclusion

Choosing between ReactJS and jQuery depends on your project's requirements. ReactJS is best suited for more complex, interactive, and scalable applications, while jQuery is still valuable for simpler and quick-fix tasks, you can also use it to build simple websites. For more content like this, you can follow me on twitter, let me know what you think about React and jQuery

Top comments (0)