DEV Community

Cover image for What is Virtual DOM? Difference between virtual DOM and real DOM?
Md Shah Jalal
Md Shah Jalal

Posted on

What is Virtual DOM? Difference between virtual DOM and real DOM?

In simple words, virtual DOM is just a copy of the original DOM kept in the memory and synced with the real DOM by libraries such as React DOM. This process is called Reconciliation.
Reconciliation is a process to compare and keep in sync the two files (Real and Virtual DOM). Diffing algorithm is a technique of reconciliation that is used by React.

Real DOM

  • DOM is a language-neutral interface allowing programs and scripts to dynamically access and update multiple objects like content, structure, and style of a document.
  • The DOM denotes the document as nodes and objects.
  • It is an object-oriented representation of a web page, modified with a scripting language like JavaScript.

Virtual DOM

  • Is a collection of modules designed to provide a declarative way to represent the DOM for an application.
  • A virtual DOM object is a representation of a DOM object, like a lightweight copy.
  • Virtual DOM is ideal for mobile-first applications.

Top comments (0)