|
|
|
|
|
by ptx
1865 days ago
|
|
> virtual DOM diffing ... is becoming increasingly irrelevant as apps are moving towards more and more reactive architecture Could you expand on this? What was it that necessitated DOM diffing before, and which architectural changes are making it irrelevant? |
|
If you tried to solve this problem by redrawing the DOM every time your app state changed somewhere in the code, the browser would freeze and all your form elements would be defocused on every update, scroll states would be reset etc. etc.
React solved this by the diff algorithm and doing surgical updates of the dom based on the components state. It does this by manually reading the state, keeping a virtual DOM in its memory and doing diff calculations.
But if your whole app is reactive by design, there's no need to read the app state, doing diffing or figuring out which DOM node to update which one not to update. The DOM update operations flow naturally by the declarations given by the programmer. Frameworks such as Svelte are moving into this direction and they're already seeing quite significant performance improvements compared to VDOM implementations.