4 ms·
Virtual dom is an implementation decision for performance a developer shouldn't even be very aware of. The main upside to react is that it has a huge ecosystem.
by kabes 7y ago
Virtual dom is an implementation decision for performance a developer shouldn't even be very aware of. The main upside to react is that it has a huge ecosystem.
- Waterluvian 7y agoYou should at least be aware of the gist, lest you obsess over premature optimization. 1. Changes to the DOM cost a ton more than executing JS code. 2. So don't feel too bad when a render() gets called that doesn't change anything because the virtual DOM swallows that.
- spankalee 7y ago> 1. Changes to the DOM cost a ton more than executing JS code. The point of the article, and of the performance problems that people actually have with React is that this might be true for a small number of JS operations, but that 1) Tree diffs are computationally complex operations that add up for real-sized apps 2) The diff is actually unnecessary if you simply take into account the structure of templates, so diffs are pure overhead. So _do_ feel bad when you have a no-op render() in React at least, because the resulting VDOM diff just chewed up CPU and battery for no reason.