Virtual DOM

Visakh Vijayan - Nov 16 '18 - - Dev Community

So why is react fast. They are saying the magic is because of the virtual DOM.

A virtual DOM is a programming concept by which the system stores a copy of the DOM in the memory.

Whenever a change occurs to the VDOM, it's compared with the old VDOM and only those changes are committed to the actual DOM.

This is also called "diffing".

If we don't use React it takes a lot of time and APIs that the browser has to call to update the DOM. But with React it's easier to update the VDOM as it's a JS object. This object is optimized in such a way that it makes minimum calls to the browser DOM to update it.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .