|
|
|
|
|
by austin-cheney
671 days ago
|
|
React came out in 2013. At that time object manipulation would likely have been, at best, only marginally faster than writing to the DOM. First, you have to understand that at that time Firefox was about 500x faster at accessing the DOM than Chrome and about 250,000x faster accessing the DOM via the API methods than via querySelectors. Firefox and Chrome performed about equally in use of querySelectors with Chrome being a tiny bit faster. So, the DOM was already fast, but occupied a different memory space than JS. At any rate the original motivation had nothing to do with performance. The goal was to introduce a template system that fit with React’s state/component system. JS modules weren’t a thing yet, so code organization was very different at that time and centered around concepts like AMD and Common.js, though it was mostly some form of AMD typically require.js. The design of the template system in Vue was created to solve for the exact same conditions according to the internal organization of Vue. |
|
https://jsben.ch/cSWJa
- JS object appears to be at least 2x faster than document.createElement() (Chrome)
- Note: JS object only loosely represents JSX element so it is a bit unfair. But with actual JSX objects I would assume it is still somewhat faster than the DOM API.
https://youtu.be/DgVS-zXgMTk&t=1532
- Pete Hunt, one of the React devs, says "JSX is faster than the DOM because it is JS memory."