# Is ReactJS really fast?

> No.

Hard to believe?

Most developers and decision-makers take it for granted that ReactJS is a super fast alternative to other frameworks like AngularJS and EmberJS.

It has gotten to the point that no one even questions things like this:

![oh what?][1]

[(Source)][2]But if you ask yourself where this belief comes from, you might be surprised.

### Everyone says it

This doesn’t give us much to argue to with, so we won’t bother.

### Virtual DOM

We all understand that DOM manipulation by the browser is slow.

This is where ReactJS came in and introduced the new idea of using a [Virtual DOM][3]. By calculating the difference between the future state and the current one, it can minimize the amount of DOM requests.

Intuitively, this sounds like a major performance improvement. But what about the performance impact caused by the massive amounts of JavaScript required to execute this complicated feat?

Or the strange lack of any demonstrable examples of the performance improvements achieved by this feature… except the comparison demos.

### We have all seen the demos

This is perhaps the biggest culprit. So let us take a closer look at a few.

#### React.js Conf 2015 – Hype!

This is perhaps [the most watched one][4]. This presentation literally made the crowd go “wow”.

Here is the original demo:

Wow, right?

Let’s not take it at face value though. If we give it a closer look we find something very surprising. The demo’s author seems to neglect one of the most basic speed improvements that can be effected in Angular – [“track by”][5].

Let’s fix that by changing a single line of code:

ng-repeat=”(key, db) in databases”

ng-repeat=”(key, db) in databases track by key”

* [Try the result][6]

![oh what?][7]

Surprised? Sadly, AngularJS deserves some blame for that. The most common speed improvement is unfortunately badly documented and not auto-suggested by the framework.

This little change invalidates 95% of comparisons between ReactJS and AngularJS.

#### Next up: ng-conf: Angular + React

[The next most popular presentation][8] contains a similar “wow” moment.

* [Try it out][9]

Here the issue is different. The comparison is not between rendering but rather between rendering ReactJS Components and rendering **and data handling** of AngularJS.

ReactJS is being told explicitly which cell changed while AngularJS is left with a generic “something changed” notification – forcing it to recheck everything.

Let’s level the playing field and give both frameworks the same information by using AngularJS’s [isolated scope][10]:

$timeout(function() {
$scope.status.isSearching = false;
$scope.status.searchResults = …

Updated to:

setTimeout(function() {
$scope.status.isSearching = false;
$scope.status.searchResults = …

* The result? [Try it out][11].

_The above can be done on newer versions of angular by using $timeout([func], [timeout], false);_

### What does all this mean?

It appears that Virtual DOM-based frameworks (and, specifically, ReactJS) offer no demonstrable improvement over “plain” frameworks like AngularJS or EmberJS. The premise that adding ReactJS to AngularJS will magically improve performance is simply not based on factual data.

And while ReactJS itself offers a host of other improvements, I could not find any demonstration of the most commonly quoted advantage of speed.

### Is ReactJS Bad?

No. ReactJS is a great framework which [we at 500Tech][12] use and love. There are many benefits to choosing ReactJS for your next project. “Speed” should not be one of them.

### Notes

* Any demonstrations that show speed boosts resulting from the Virtual DOM are most welcome.
* Please do your [AngularJS performance homework][13] before sending them over.
* [Original presentation][14] for [ng-conf Israel][15]
* Since “fast” is a relative term, AngularJS was used as the comparison base. Both because it solves similar problems as ReactJS and both since it is usually used as the base comparison anyway.
* While its easy to show that ReactJS is faster than AngularJS in certain cases, it is much harder to show that it is _always_ slower. Over the next week we will release the various samples we wrote to test the speed differences.

### Updates

– _People have sent me links to a number of other demos. All are simply missing ‘track by’._

> In theory there is no difference between theory and practice. In practice there is.

### Comments

[Discussion on HackerNews][16]

[0]: https://twitter.com/intent/user?screen_name=BorisDinkevich
[1]: http://speed.examples.500tech.com/speed.png
[2]: http://jsblocks.com/#performance
[3]: https://facebook.github.io/react/docs/glossary.html
[4]: https://www.youtube.com/watch?v=z5e7kWSHWTg
[5]: https://docs.angularjs.org/api/ng/directive/ngRepeat#tracking-and-duplicates
[6]: http://speed.examples.500tech.com/ngrepeat/after/angular.html
[7]: http://speed.examples.500tech.com/dog-dude-wait-what.jpg
[8]: https://www.youtube.com/watch?v=XQM0K6YG18s
[9]: http://speed.examples.500tech.com/digest/before/
[10]: https://egghead.io/lessons/angularjs-understanding-isolate-scope
[11]: http://speed.examples.500tech.com/digest/after/
[12]: http://500tech.com
[13]: http://www.slideshare.net/nirkaufman/angularjs-performance-production-tips
[14]: http://www.slideshare.net/borisdinkevich/using-reactjs-in-angularjs
[15]: http://ng-conf.co.il
[16]: https://news.ycombinator.com/item?id=9638305
[17]: http://blog.itlater.com