3 ms·
So, maybe i'm misunderstanding, but, the perf advantage is that react waits until the next RAF and then only updates the parts of the DOM that actually changed?
by Joeri 13y ago
So, maybe i'm misunderstanding, but, the perf advantage is that react waits until the next RAF and then only updates the parts of the DOM that actually changed? So, now i'm wondering: why can't the browser do that? Isn't this whole middle-man approach something to eventually be optimized out?
- polarix 13y agoSure, the browser could implement a virtual dom and then sync it and do a reflow once per frame.
- fbender 13y agoYou can do that with the help of `document.createDocumentFragment()`.
- peterhunt 13y agoThe browser does do this already to an extent. The difference is that React constrains the operations a user can do (i.e. we only give them the DOM node if they explicitly ask for it and only let them manipulate it at certain times) so we eliminate the operations that cause the DOM to be slow. If the DOM were to implement this it'd have to break backwards compatibility.