Skip to main content
Web DevPerformance & OptimizationDiagramIntermediate

Virtual Scrolling

KO: 가상 스크롤 (Virtual Scrolling)·EN: Virtual Scrolling·JA: 仮想スクロール(Virtual Scrolling)·Windowing

A rendering technique (windowing) that mounts only the small slice of list items currently visible in the viewport, keeping DOM size constant at 60fps

Table of Contents

Structure Diagram

Mounted DOM Nodes by List Size: Full Render vs Virtualized
Fixed ~20 Visible NodesMemory & Layout BottleneckTotal Items (100 – 100,000) →Mounte
(50, 58)Full DOM Render (Lag) #3
Quick Answer

What is Virtual Scrolling?

A rendering technique (windowing) that mounts only the small slice of list items currently visible in the viewport, keeping DOM size constant at 60fps. It is a core concept in Performance & Optimization within Web Dev.

Core Principles

Virtual scrolling (windowing) avoids mounting thousands of DOM elements for long lists. Instead, it renders only the 15–20 rows visible in the viewport plus a small overscan buffer, while a tall spacer container preserves an accurate native scrollbar.

As the user scrolls, the virtualizer computes the visible index range from scrollTop and positions those rows via transform: translateY(...), keeping DOM node count and layout cost O(1) regardless of whether the dataset has 500 or 100,000 items.

Practical Takeaways

  • Fixed vs. dynamic row heights: Fixed heights yield trivial math and maximum speed. For variable-height feeds or chat logs, use a dynamic virtualizer (like @tanstack/react-virtual) that measures rows with ResizeObserver.
  • Tune overscan: Rendering 3–5 extra items above and below the viewport prevents blank flashes during fast flings.
  • Account for Ctrl+F and accessibility: Unmounted rows won't match native browser find (Ctrl+F). Provide in-app search and set aria-rowcount / aria-rowindex for assistive technologies.

Notable Examples

  • Slack, Discord, and cloud log viewers: Smoothly scroll through tens of thousands of chat messages or log lines without bloating memory.
  • Enterprise data grids (AG Grid, TanStack Virtual): Virtualize both rows and columns to render massive spreadsheets at 60fps.