# Virtual DOM

> A copy of the page kept in memory. The app checks two copies and fixes only what changed.

**Field:** Software Development  
**Category:** Web Development  
**Also known as:** VDOM, Virtual Document Object Model, DOM Diffing

## Think of it like

It is like checking a new list with the old one. Then you fix just the lines that changed.

## Definition

A virtual DOM is a light copy of the page that a UI library keeps in memory. When data changes, the library builds a new copy. It compares the new copy with the old one to find what is different. Then it changes only those parts of the real page. Changing the real page is slow, so doing it less keeps the app fast. React and Vue both work this way.

## Example

Lucy's list has 500 rows, and one price changes. The virtual DOM finds that one change, so only one line on the page is redrawn.

## Why it matters

You can write code as if the whole page is redrawn each time. The library does the careful, small updates for you.

## Common mistake

Thinking it makes every app fast. It saves work on the real page, but the comparing has a cost of its own.

## Three principles

- **A copy in memory.** Light to build and to compare.
- **Compare, then patch.** Only the changes reach the page.
- **You write simply.** The library handles the updates.

## Related terms

- [Document Object Model (DOM)](https://learn.benibix.com/term/development/dom)
- [React](https://learn.benibix.com/term/development/react)
- [Vue.js](https://learn.benibix.com/term/development/vue)
- [UI Component](https://learn.benibix.com/term/development/component)
- [UI State](https://learn.benibix.com/term/development/state)
- [React Hooks](https://learn.benibix.com/term/development/react-hooks)

## Told apart from

- [Virtual DOM vs DOM](https://learn.benibix.com/compare/virtual-dom-vs-dom): People think the virtual DOM is a faster DOM that the browser has, and it is not. The DOM is the real page the browser draws. The virtual DOM is a copy a library like React keeps in memory. The library compares two copies and then changes the real DOM as little as it can.

![A button calls setCount(1), a React Hook that changes state. The component makes a new virtual tree, drawn beside the old one. The two trees are compared, and only one node differs: the text 0 has become 1. An arrow carries just that one change to the real page in the browser.](https://learn.benibix.com/diagrams/dev5-virtual-dom.svg)

---

Source: https://learn.benibix.com/term/development/virtual-dom
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
