React is the front end library of Javascript and its not a complete framework. Most of the complex tasks such as routing, form validation, data fecthing are done by some other supporting libraries of React.
So, here are some of the reasons which makes react much faster-
React follows Declarative approach that means you dont need to worry about the DOM updation and rendering as it used to be in Jquery or in plain Javascript. React does everything to update it faster.
React uses bundlers such as webpack or parcel that makes lots of things such a minification, bundling, uglification of code and image size reduction to minimize the size of the final bundle.
Also, it does the tree-shaking where the unused code is discarded and a compressed build file is created.
It does the translation of the ES6 and typescript code to browser-compatible plain javascript.
Also, it provides the Hot Module replacement and dev server locally and ES linting so that you can check the errors right away on the console.
React uses the Virtual DOM so that whenever the variable or state changes in the component, it creates another DOM like Object in the memory and comparison between these two Objects takes place with the diffin algorithm.
Basically, the DOM operations are very expensive to perform hence the virtual DOM object comparison takes place in React that makes it faster to compare the JS objects than the HTML elements of the actual DOM.
Reconciliation is the process that makes updates to the actual DOM with the difference found in the comparison of virtual dom objects.
React follows the unidirectional data flow that makes the tracking of the state updates easier.
React also provides the server-side rendering option
So, these are some of the advantages that make the React app faster as compared to the Angular or VueJS application.
Also, all the libraries are coming up with enhanced features in every release, so it all depends on the use case for the speed comparison. One can prepare a use case to prove whether React is faster or Vue/Angular. So, I'm just giving my two cents regarding the internals of React. We cant say React would be faster or some other framework for sure. There should not be any argument on it.
Top comments (4)
uhh, the points you made don't actually prove that react is faster than vue or angular.
it just shows the amazing features that the library has.
vue has server side rendering like react, vue also uses the virtual dom.
And also you mentioned something about React using webpack....i do not see you mentioning Vite so i'm guesssing that maybe you just started using React(which is not a bad thing, i mean we all learn).
Vite is faster than Webpack in build time.
There are so many things that affect performance.
I suggest you dive deeper than just listing the features that React provides.
React is good, no doubt.
I use it a lot. But for me, I prefer Vue.
Small and minimal, and the build time is extremely quick...
The only part where i'd pick React is for Next.JS over NuxtJS...that is where React thrives like a God
How this is make faster than vue? Instead of declaring the statements, please learn other libraries too, atleast do some codes on that.
All the libraries are coming up with enhanced features in every release, so it all depends on the use case for the speed comparison. One can prepare a use case to prove whether React is faster or Vue/Angular. So, I'm just giving my two cents regarding the internals of the React.