Hack Frontend Community

What is Virtualization and Why is it Needed

Virtualization is a technique in interface development where only visible part of large list or table is rendered in DOM, not entire data volume at once.

Invisible elements aren't created or are reused, and during scrolling — dynamically loaded and replaced. This approach significantly reduces browser load and makes interface more responsive.


Why Virtualization?

1

Performance improvement

Fewer elements in DOM — less browser load. This speeds up render and reduces lags during interaction.

2

Memory saving

Only visible part of data is rendered, which is especially critical when working with thousands of rows in list or table.

3

Interface smoothness

Scrolling and element interaction become much faster as DOM isn't overloaded with "extra" elements.


When to Use Virtualization?

  • When displaying large lists (1000+ elements)
  • In tables with many rows
  • In infinite scroll
  • When working with tree structures (e.g., file system)
  • In interfaces where response speed and scrolling are important

How Virtualization is Implemented

React doesn't have built-in virtualization, but it's easily implemented using libraries:

Example with react-window

import { FixedSizeList as List } from 'react-window';

const Row = ({ index, style }) => (
  <div style={style}>Element #{index}</div>
);

<List
  height={400}
  itemCount={10000}
  itemSize={35}
  width={300}
>
  {Row}
</List>

Here DOM will have maximum 20–30 elements — despite having 10,000 data items.

BeforeAfter
Load speedLong list loadingAlmost instant render
DOM sizeDOM with thousands of elementsOnly visible part in DOM
Scroll performanceLags during scrollingSmooth scrolling

Summary:

Virtualization is key to performance when working with large volumes of UI data. It saves resources, speeds up interaction and makes interface responsive.