|
|
|
|
|
by spoiler
672 days ago
|
|
DOM interactions (read, writes) are synchronous, they're very slow, and it must happen on the main thread. This can cause the browser tab to freezing if access and updates aren't carefully "curated" (ie you don't want to read-check-then-write in a tight loop; or even write too often, even if it's the same value). It can also simplify some stuff surrounding event handling (but that's not it's main goal I think) So people wrote various ways to defer/batch/denounce updates. Virtual DOM is a general solution/implementation. It's not the only one, but I think you always need at least a tiny runtime to avoid too much DOM access (ie Svelte, Solid JS are fairly minimal) |
|
Unless you use lit-html, which has a very efficient diffing algorithm that only updates the nodes that have changed.