What really makes ReactJS as fast as it claims to be?

React isn't exceptionally fast, it's fast enough. The real value of React is the declarative api it provides which lets you write better code.

Manual DOM operations have much higher potential performance, but you end up with difficult to maintain, hard to read code. This is unacceptable in large applications which is why we turn to tools like React.

Virtual DOM diffing is expensive. Usually, not expensive enough to cause you to drop frames. The difference between 1ms and 16ms for an update is nothing. All that matters is that you stay within the frame, which is why React's performance overhead is acceptable.


You're probably right, in this case jQuery might be faster (I haven't tested). But consider this, why are you using jQuery - wouldn't it be even faster if you did

document.getElementById("MyID").className = document.getElementById("MyID").className.replace(/\bred\b/,'');
document.getElementById("MyID").className = document.getElementById("MyID").className + ' blue';

So really, we're not trying to compete raw speed here, otherwise you would just write in pure javascript and I know companies that do this purely to be faster on mobile.

The benefits of a framework is maintenance and speed of development. Programming in pure javascript is a lot harder to scale and maintain than jQuery and similarly programming in jQuery is a lot harder to scale and maintain than React. Although the converse is true, it's much faster to get a working app with minimal functionality with jQuery (but after you build your mvp, it becomes much harder to maintain)

In small codebases jQuery might be faster than React, but when you work with larger codebases, you'll find heaps of duplicate and redundant code in jQuery and it becomes inherently slower. React however, is different - first React, segregates everything into components so it becomes much easier to reuse, second React has a cool internal engine that prevents useless rendering from slowing down your app.

So yes you are right, jQuery can be faster than React but that's really missing the point of React. Just as pure javascript might be faster than jQuery, but that's missing the point of jQuery.