- For you to have a better understanding of why you might want to use a virtual DOM, you must look at the problems that led us to the virtual DOM.
- The virtual DOM is more efficient than direct DOM manipulation because it patches the DOM with the necessary changes avoiding unnecessary repaints and re-renders.
- Whenever you have any changes i.e. you want to add another div to your DOM then the virtual DOM will be created which actually does not do any changes in the actual DOM. Now with this virtual DOM, you will be checking the difference between this and your current DOM.
- Creation of the DOM tree — Once the browser receives a HTML file, the render engine parses it and creates a DOM tree of nodes, which have a one-one relation with the HTML elements.
- People often throw around the statement “The DOM is slow”.