A lightweight Virtual DOM library built from scratch in vanilla JavaScript to explore how modern UI frameworks perform rendering, reconciliation, and targeted DOM updates.
OutDOM is a learning-focused implementation of a Virtual DOM system. It demonstrates how UI libraries can represent interfaces as JavaScript objects, compare changes efficiently, and update only the necessary parts of the DOM.
- Virtual DOM representation
- Element creation helper (
h) - Recursive renderer
- Event handling system
- Reconciliation (diffing)
- Prop diffing and patching
- Targeted DOM updates
- Interactive counter demo
src/
├── app.js # Demo application
├── h.js # Virtual DOM element creation helper
├── main.js # Application bootstrap and updates
├── reconciler.js # Diffing and reconciliation logic
└── renderer.js # Virtual DOM → Real DOM renderer
public/
└── image.png # Project screenshot
index.html
index.css
README.md
UI elements are represented as plain JavaScript objects.
{
type: "button",
props: {
onClick: handleClick
},
children: ["Click Me"]
}The renderer recursively converts Virtual DOM nodes into real DOM elements.
Virtual DOM
↓
Renderer
↓
Real DOM
Whenever application state changes, a new Virtual DOM tree is generated.
The new tree is compared against the previous tree to detect differences.
Only the affected DOM nodes are updated, avoiding unnecessary DOM operations.
Old Tree
↓
Compare
↓
New Tree
↓
Patch DOM
The included counter application demonstrates:
- Increment
- Decrement
- Reset
- Event handling
- Reconciliation
- Targeted DOM updates
Each interaction generates a new Virtual DOM tree and triggers reconciliation against the previous tree.
const vnode = h(
"button",
{
onClick: () => console.log("Clicked!")
},
"Click Me"
);The Virtual DOM node is rendered into the DOM and later reconciled against future updates.
Clone the repository:
git clone https://github.com/itisrudraa/OutDOMNavigate into the project:
cd outdomStart a local server:
npx live-serverOr use the VS Code Live Server extension.
This project was built to better understand:
- Virtual DOM architecture
- Recursive rendering
- DOM diffing strategies
- Reconciliation algorithms
- Event binding
- Efficient UI updates
OutDOM is intended as an educational project rather than a production-ready framework.
- Virtual DOM representation
- Recursive renderer
- Event listeners
- Reconciliation
- Text node updates
- Prop updates and removal
- Event listener updates
- Node creation and replacement
- Fragment support
- Keyed reconciliation
- Component abstraction
- Hooks / state system
- JSX transform support
- Improved diffing optimizations
The goal of OutDOM is not to compete with established frameworks, but to understand the ideas behind them by building the core pieces from scratch.
By implementing rendering, diffing, and reconciliation manually, the project provides a practical look into how libraries such as React update user interfaces efficiently.
MIT
