You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/comparison.md
+46-4Lines changed: 46 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -33,9 +33,51 @@ When rendering UI, manipulating the DOM is typically the most expensive operatio
33
33
34
34
In React, let's say the additional overhead of rendering an element is 1 and the overhead of an average component is 2. In Vue, the overhead of an element would be more like 0.1, but the overhead of an average component would be 4, due to the setup required for our reactivity system.
35
35
36
-
This means that in typical applications, where there are many more elements than components being rendered, Vue will outperform React by a significant margin. To demonstrate this, let's render a list of 10,000 items in a single component. In Chrome 52 on my 2014 Macbook Air, [Vue renders](https://jsfiddle.net/chrisvfritz/859gL422/) in an average of 60ms, while [React renders](https://jsfiddle.net/chrisvfritz/65ojbkab/) in an average of 127ms.
37
-
38
-
In extreme cases however, such as using 1 normal component to render each element, Vue will usually be slower. When modifying the previous examples accordingly, [Vue renders](https://jsfiddle.net/chrisvfritz/mk8jaqpg/) in ~585ms, while [React renders](https://jsfiddle.net/chrisvfritz/2sx0341o/) in ~157ms! This isn't the end of the story though. Both Vue and React offer functional components, which are preferred in situations like this. Since functional components are closer to the cost of elements, Vue is once again on top, with [~73ms](https://jsfiddle.net/chrisvfritz/413wjqyf/) vs [~144ms](https://jsfiddle.net/chrisvfritz/kss01xg7/) - and this performance boost only required adding a single line for Vue: `functional: true`.
36
+
This means that in typical applications, where there are many more elements than components being rendered, Vue will outperform React by a significant margin. In extreme cases however, such as using 1 normal component to render each element, Vue will usually be slower. This isn't the end of the story though.
37
+
38
+
Both Vue and React also offer functional components, which are stateless and instanceless - and therefore, require less overhead. When these are used in performance-critical situations, Vue is once again faster. To demonstrate this, we built a simple [benchmark project](https://github.com/chrisvfritz/vue-render-performance-comparisons) that just renders 10,000 list items 100 times. We encourage you to try it yourself, as the results will vary depending on the hardware and browser used - and actually, they'll vary even between runs due to the nature of JavaScript engines.
39
+
40
+
If you're feeling lazy though, below are the numbers from one run in Chrome 52 on a 2014 MacBook Air. To avoid cherry-picking, both benchmarks were actually run 20 separate times, with results from the best runs included below:
41
+
42
+
{% raw %}
43
+
<tableclass="benchmark-table">
44
+
<thead>
45
+
<tr>
46
+
<th></th>
47
+
<th>Vue</th>
48
+
<th>React</th>
49
+
</tr>
50
+
</thead>
51
+
<tbody>
52
+
<tr>
53
+
<th>Fastest</th>
54
+
<td>23ms</td>
55
+
<td>63ms</td>
56
+
</tr>
57
+
<tr>
58
+
<th>Median</th>
59
+
<td>42ms</td>
60
+
<td>81ms</td>
61
+
</tr>
62
+
<tr>
63
+
<th>Average</th>
64
+
<td>51ms</td>
65
+
<td>94ms</td>
66
+
</tr>
67
+
<tr>
68
+
<th>95th Perc.</th>
69
+
<td>73ms</td>
70
+
<td>164ms</td>
71
+
</tr>
72
+
<tr>
73
+
<th>Slowest</th>
74
+
<td>343ms</td>
75
+
<td>453ms</td>
76
+
</tr>
77
+
</tr>
78
+
</tbody>
79
+
</table>
80
+
{% endraw %}
39
81
40
82
#### Update Performance
41
83
@@ -162,7 +204,7 @@ React is renowned for its steep learning curve. Before you can really get starte
162
204
While Vue scales up just as well as, if not better than React, it also scales down just as well as jQuery. That's right - all you have to do is drop a single script tag into a page:
Then you can start writing Vue code and even ship the minified version to production without feeling guilty or having to worry about performance problems.
0 commit comments