2 ms·
> If that were true how would virtual DOM ever be faster than the DOM? It would still have to update the DOM itself. It uses a very smart algorithm to diff two
by littlecranky67 6y ago
> If that were true how would virtual DOM ever be faster than the DOM? It would still have to update the DOM itself.
It uses a very smart algorithm to diff two vDOMs (previously rendered vs. newly rendered) and "calculates" a minimal* set of operations required to get the current DOM (=prev. rendered vDOM) into the new state of the DOM (=result from current vDOM render).
Think in source code patches produced by tools like diff: A patch between two different code tree versions can fit just a few lines and is quickly applied against the tree, while shipping and writing the full tree is more expensive.
*: ideally it would be minimal in a sense there is no smaller/faster representation, but thats of course not the case in real applications.