# Render Tree & Layout vs Virtualized Lists & Windowing

- **Canonical URL:** https://frontend.rocks/vs/render-tree-layout-vs-virtualized-lists-windowing/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** Full-list DOM rendering forces layout over thousands of off-screen boxes, whereas virtualization caps active layout nodes to the viewport.

## Comparison Matrix

| Dimension | Render Tree & Layout | Virtualized Lists & Windowing |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Baseline · Widely |
| **Domain** | Rendering Pipeline | State & Architecture |
| **Mental Model** | Cut layout thrashing and oversized DOM reflow costs—the Render Tree prunes display: none subtrees before Layout computes exact box geometry. | Keeps DOM node count O(1) relative to dataset size by mounting only the rows visible in the scroll viewport plus an overscan buffer inside a full-height spacer. |
| **Prerequisites** | DOM & CSSOM Construction (Render Tree construction cannot begin until DOM nodes and CSSOM rules exist.); Browser Rendering Pipeline (Critical Rendering Path) (Layout is the geometry-solving stage inside the main-thread frame pipeline.) | Browser Rendering Pipeline (Critical Rendering Path) (Rendering 10,000+ DOM nodes chokes style recalculation and layout passes; windowing caps active nodes.); JS ResizeObserver Pattern for Adaptive Layout (Variable-height virtualized rows rely on ResizeObserver to measure and cache actual row heights.) |
| **When Not to Use** | When not to use display: none: Avoid display: none for elements toggled every frame or holding measured scroll positions; use visibility: hidden or content-visibility: hidden instead. | When not to use JS Virtualization: For lists under ~500 simple rows, native DOM + CSS content-visibility: auto; contain-intrinsic-size: 0 64px; preserves Cmd+F search, text selection, and accessibility with zero JS complexity. |

## Render Tree & Layout — Under the Hood
Blink constructs the Render Tree by pairing visible DOM nodes with resolved `ComputedStyle` structs, omitting `display: none` subtrees while keeping `visibility: hidden` boxes in flow. Like a carpenter's cut-list, anything marked `display: none` is crossed off before Layout measures widths, heights, and coordinates.

1. **Style Recalc**: The engine resolves cascade rules for every DOM element into a `ComputedStyle` struct.
2. **Box Generation**: Visible elements generate one or more layout boxes (including anonymous boxes for bare text runs and `::before` pseudo-elements).
3. **Geometry Solving**: Layout traverses the box tree to compute intrinsic sizes, line breaks, and viewport-relative coordinates.

```css
/* Omitted from Render Tree: 0 layout cost, no box generated */
.collapsed-panel { display: none; }

/* Kept in Render Tree: reserves space and participates in Layout */
.invisible-placeholder { visibility: hidden; }
```

Once [DOM & CSSOM Construction](/concepts/dom-cssom-construction) finishes, reading geometry properties like `offsetWidth` prematurely triggers [Layout Thrashing](/concepts/layout-thrashing).

## Virtualized Lists & Windowing — Under the Hood
A virtualized list behaves like a train window: the landscape has 50,000 trees, but only 15 trees exist outside the glass at any moment. Inside a single tall spacer container (`height: totalRows * rowHeight`), the list computes visible indices from `scrollTop` and positions rows via [GPU Compositor Layers](/concepts/gpu-compositor-layers) (`translateY`).

1. Compute `startIndex = Math.max(0, Math.floor(scrollTop / rowHeight) - overscan)` and `endIndex` from container height.
2. Render only `items.slice(startIndex, endIndex)` with `transform: translateY(${i * rowHeight}px)`.
3. For dynamic-height rows, attach a [ResizeObserver](/concepts/js-resize-observer-pattern) to measure rendered items once and update a prefix-sum offset table.

```js
function getVisibleRange(scrollTop, viewportHeight, rowHeight, total, overscan = 4) {
  const first = Math.floor(scrollTop / rowHeight);
  const count = Math.ceil(viewportHeight / rowHeight);
  return {
    start: Math.max(0, first - overscan),
    end: Math.min(total, first + count + overscan),
  };
}
```

## Interactive Labs & Dissections
- [Render Tree & Layout Lab](https://frontend.rocks/concepts/render-tree-layout/#lab) ([Markdown](https://frontend.rocks/concepts/render-tree-layout.md))
- [Virtualized Lists & Windowing Lab](https://frontend.rocks/concepts/virtualized-lists-windowing/#lab) ([Markdown](https://frontend.rocks/concepts/virtualized-lists-windowing.md))

## Related Architecture Autopsies
- [Autopsy #07: Green CI, Broken Prod: What JSDOM Hid From Your Tests](https://frontend.rocks/autopsies/green-ci-broken-prod-jsdom/) ([Markdown](https://frontend.rocks/autopsies/green-ci-broken-prod-jsdom.md)): 100% of unit and component tests pass in CI while the mobile navigation dropdown is completely unclickable in production.

## Primary Sources
- https://drafts.csswg.org/css-display-3/
- https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/Critical_rendering_path
- https://developer.mozilla.org/en-US/docs/Web/CSS/content-visibility
- https://web.dev/articles/virtualize-long-lists-react-window
- https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-rowcount
