DEV Community

Discussion on: I created a Quiz app using Svelte and now I cannot go back to any other framework.

Collapse
 
manan30 profile image
Manan Joshi • Edited

Long story short: Diffing isn't free


Explanation

The main reason we have been using things like VDOM is to compare if the data has changed or not and if so when to re-render the new changes. There are many diffing algorithms that are fast and we would update something if it has changed, but updating things directly will always be faster. In libraries like React the virtual DOM tries to compare its state with the current DOM state and if there is any difference it will ask the reconciler to apply those changes to the DOM. The part where it gets slow is the reconciliation phase. This is because diffing isn't free. It is nothing but just pure overhead. For more info, this is what the react docs have to say about virtual dom and this is what Svelte has to say about it.

Collapse
 
opshack profile image
Pooria A

Thank you for the answer, the article on the Svelte website makes total sense. I guess I need to learn more about how Svelte is updating the DOM without any diffing algo.