All topics
Performanceadvanced

Windowing / List Virtualization

Learn how virtualization renders only the visible slice of a large list, keeping DOM size and render cost constant regardless of total item count.

List virtualization (windowing) renders only the subset of a large list's items currently visible within (or near) the scrollable viewport, rather than rendering every single item into the DOM up front. Libraries like react-window and react-virtualized implement this by measuring the container's scroll position and calculating which item indices are currently visible, rendering only those, and using absolute positioning (or transform) to place them correctly within a container sized to represent the full list's total scrollable height.

Virtualization is like a scrolling ticker display that only physically lights up the handful of characters currently in the visible window, even though the full message is much longer — the display doesn't need physical bulbs for every character in the whole message, just enough to show whatever's currently passing through the visible frame.

Key Concepts

1
Without virtualization, rendering a list of tens of thousands of rows creates tens of thousands of real DOM nodes, which is expensive both to initially create and to keep around — layout, memory, and even simple browser operations like scrolling can degrade noticeably as DOM size grows. Virtualization keeps the number of actual DOM nodes roughly constant (proportional to the viewport size, not the total data size), regardless of whether the underlying list has 100 or 100,000 items.
2
The container element uses a fixed or dynamically measured height per row to compute a large 'phantom' scrollable area (via a spacer element or padding) that gives the scrollbar the correct total size, while the actual rendered rows are a small, constantly-updating window that shifts as the user scrolls, recycling the same small set of DOM nodes rather than creating new ones for every item ever scrolled past.
3
Interviewers ask about virtualization specifically for very large lists or tables, and expect candidates to recognize the core tradeoff: added implementation complexity (row height management, dynamic sizing) in exchange for constant-time rendering performance regardless of total list size, which plain .map() rendering cannot offer past a certain scale.
.map()