You're Rendering Too Much: The Case for List Virtualization

This post explores list virtualization through a React lens. The concept applies broadly, but the libraries and code examples are React-specific.

The Problem

You're building an admin dashboard. The product manager wants to show all 12,000 user records in a scrollable list — no pagination, "users hate clicking next." You shrug, map over the array, and ship it.

{items.map(item => (
  <div key={item.id} className="list-item">
    {item.name}
  </div>
))}

Then your browser tab starts choking.

Here's what's happening under the hood. Every <div> you render for each list item becomes a DOM node. The browser needs to lay it out, paint it, and keep track of it — all 12,000 of them. Even if 11,980 are completely off screen and invisible to the user, they still exist in memory. Layout calculations cascade. Scroll events trigger style recalculations across the entire tree.

Open Chrome DevTools while scrolling and you'll see it clearly: frame times jumping to 50–100ms, frames dropping well below the 60fps threshold that separates "smooth" from "janky." On a mid-range machine or a phone, it's not just slow — it freezes. Rendering 10,000 items without virtualization typically stalls the UI for 3–5 seconds on first load.

The list isn't the problem. The DOM is.

If you want to feel this before reading further: open the live demo, click "No Virtualization," and scroll. Watch the FPS drop and the render time. Then come back.


The Natural Instincts (And Why They Fall Short)

When a list gets slow, most developers reach for one of three things:

Pagination. Split the data into pages, only load 50 items at a time. This works well for tables and search results, but it kills scroll-based UIs. If you're building a feed, a log viewer, or anything that feels continuous — pagination breaks the experience. You've solved the performance problem by removing the feature.

Infinite scroll / lazy loading. Load data in batches as the user scrolls down. This is better — but it only delays the problem. Every batch you load adds more DOM nodes. After a user scrolls through 500 items, all 500 are still mounted. Come back after 3,000 items and the browser is right back where it started: sluggish, memory-heavy, struggling.

CSS tricks. content-visibility: auto is genuinely useful — it tells the browser it can skip painting off-screen elements. But the DOM nodes are still there. The browser still parses them, still tracks them in memory, still considers them for layout. You've reduced paint cost; you haven't reduced node count.

Each of these fixes a symptom. None of them touch the root cause.


What Virtualization Actually Does

The real problem is simple: you're maintaining DOM nodes for items the user can't see. So the fix is equally simple: don't.

List virtualization (sometimes called "windowing") keeps only the visible items in the DOM — plus a small buffer above and below the viewport. Scroll through 100,000 rows and at any given moment, only ~20 DOM nodes exist. The rest don't. They've never been created.

DOM size stays constant regardless of data size. That's the whole idea — and it's why virtualization handles what every other approach can't.


How It Works

Understanding the mechanism makes it much easier to debug issues and choose the right library. Here's the mental model:

The outer container is a fixed-height div with overflow: scroll. This is what the user physically scrolls. Its height is whatever fits your layout — say, 600px.

The inner container is set to the total height of all items combined — even the ones not rendered. If you have 10,000 items at 40px each, the inner container is 400,000px tall. This gives the scrollbar its correct proportions. The browser thinks the content is massive, because mathematically it is.

Only visible items are rendered. A scroll event listener calculates which items fall within the current viewport, then mounts just those items — positioned absolutely with transform: translateY().

┌──────────────────────────┐
│     Outer Container      │  ← fixed height, scrollable
│  ┌────────────────────┐  │
│  │  Inner Container   │  │  ← height = total items × item height
│  │  (400,000px tall)  │  │
│  │                    │  │
│  │  [item 47]  ───┐   │  │
│  │  [item 48]     │   │  │  ← Visible window (~20 items rendered)
│  │  [item 49]     │   │  │    Everything else: not in the DOM
│  │  [item 50]  ───┘   │  │
│  │                    │  │
│  └────────────────────┘  │
└──────────────────────────┘

Overscan is a small buffer — typically 2–5 extra items rendered just outside the viewport. It prevents a blank flash when the user scrolls quickly before the next batch can mount.

On each scroll tick, the math is straightforward: startIndex = Math.floor(scrollTop / itemHeight). Items that fall out of range get unmounted; new ones in range get mounted. The browser manages a small, stable set of nodes no matter how large the underlying data gets.


Picking a Library

All three major React virtualization libraries solve the same core problem. The tradeoffs come down to control, convenience, and bundle weight.

react-window is the smallest and most established. Give it a fixed item height, a count, and a render function — it handles the rest. Variable-height items are possible but require manual height pre-measurement, which adds complexity.

@tanstack/react-virtual is headless — it gives you the virtualization math and leaves all markup to you. Variable heights work without manual measurement, and despite being larger uncompressed, it's actually the lightest once gzipped. The tradeoff is boilerplate.

react-virtuoso is the highest-level option. Variable heights, reverse-scroll (chat UIs), sticky headers, and infinite scroll all work out of the box. The cost is bundle size — nearly 3× the others gzipped.

The API differences are clearest in code. Here's the same 10,000-item list in each:

react-window

import { FixedSizeList } from 'react-window';

<FixedSizeList height={600} itemCount={items.length} itemSize={40} width="100%">
  {({ index, style }) => <div style={style}>{items[index].name}</div>}
</FixedSizeList>

@tanstack/react-virtual

const virtualizer = useVirtualizer({
  count: items.length,
  getScrollElement: () => parentRef.current,
  estimateSize: () => 40,
});

<div ref={parentRef} style={{ height: 600, overflow: 'auto' }}>
  <div style={{ height: virtualizer.getTotalSize(), position: 'relative' }}>
    {virtualizer.getVirtualItems().map(row => (
      <div key={row.key} style={{ position: 'absolute', transform: `translateY(${row.start}px)` }}>
        {items[row.index].name}
      </div>
    ))}
  </div>
</div>

react-virtuoso

import { Virtuoso } from 'react-virtuoso';

<Virtuoso
  style={{ height: 600 }}
  totalCount={items.length}
  itemContent={index => <div>{items[index].name}</div>}
/>

The spectrum is clear: react-window needs a height upfront, tanstack hands you the primitives to wire yourself, react-virtuoso asks for almost nothing. More control means more code; more convenience means more bundle.

Bundle sizes (source: Bundlephobia, May 2026):

Package Version Minified Gzipped
react-window 2.2.7 12.5 KB 6.5 KB
@tanstack/react-virtual 3.13.24 17.4 KB 5.3 KB
react-virtuoso 4.18.6 57.3 KB 18.4 KB

On raw scroll performance, all three maintain smooth 60fps under normal conditions — the differences between them rarely show up in real apps. There's no definitive public benchmark separating their rendering speeds, so treat bundle size and API fit as your primary decision criteria. A rough rule of thumb: if your items are fixed-size, use react-window. If you need flexibility and full control, use @tanstack/react-virtual. If your list is complex and you want the features handled for you, use react-virtuoso.


The Takeaway

List virtualization is one of those techniques that feels like magic the first time you see a DOM tree stay flat while thousands of items scroll past. Once you understand the mechanism — a phantom full-height container, a visible window, a scroll listener doing simple arithmetic — it stops feeling magical and starts feeling obvious.

If you haven't tried it: open the demo, switch through the tabs, and watch the DOM node counter and render time. The difference between the naive tab and any of the virtualized ones makes the whole thing click immediately.