Browser engine takes more memory and layout changes for every incremental update or changes applying on the DOM. Because it involves more geometrical and mathematical calculation , which is computed on every layout changes on Browser.
However computation on browser takes less memory and it doesn't reflect anything on the DOM. This approach is made used by VirtualDOM .
So lets a take DOM , each DOM has its own properties DOM properties, these properties are simulated (using JS) .
Virtual DOM preserves state lets say its has inital state of the DOM and all propeties
So whenever there is a change Virtual DOM doesnt reflect in DOM directly instead it will do Comparison operation or Difference Operation , which will only returns properties or attributes which are changed from previous state
So it will just update only the changed property in DOM. rather than repainting the whole DOM for a minor change.
This is very efficient in web apps were ferquent updates happens , where changing a minor portion of DOM saves more memory or geometric calculation by the browser engine rather than whole section of DOM.
ex: <DIV style="color:red; background-color:white;">Hello world <span>from Foo</span></DIV>
When i change text to Hello Mars. rather than deleting and creating a new DOM.
Virtual DOM will only change the text of DIV , which doesnt affect the child <span> and other properties of DOM
See also
innerHTMLoperation (obviously the DOM is still slow but the number of operations can be optimized).O(model)andO(view)and due to pagination, tabbing, etc, there's usually fewer view pieces than model pieces to sort through when it's time to actually update the view.