What is Dom?
It’s a way of representing a structured document via objects.
The HTML DOM is always tree-structured - which is allowed by the structure of
This is cool because we can traverse trees fairly easily. Unfortunately, easily doesn’t
mean quickly here.
Manual DOM manipulation is messy.
Keeping track of the previous DOM state is tough.
Dom is slow and should be touched minimally and efficiently.
What is Virtual Dom
virtual-dom is a collection of modules designed to provide a declarative way of
representing the DOM for your app.
It is lightweight and detached from the browser-specific implementation details.
Uses cases Virtual Dom
Let you write HTML as function of state.
Let you create isomorphic apps.
Ensure best practices of DOM reconciliation.
Allows easy dom batching a performance enhancement.
Virtual Dom will re-render full app on state change.
Work with immutable data structures.
Keep node hierarchy flat.
Batch actual dom operations.
Do page profiling and check for janks.