Course contentsShow
← React
Lesson 1275 of 2,39632. Lists and Keys Deep DiveFree lesson

The Performance Problem with Long Lists

Understand why rendering thousands of DOM nodes causes slowdowns, even if most aren't visible on screen.

The Performance Problem with Long Lists

What you'll learn: Why rendering thousands of list items can slow down your React app, even when users can only see a few at a time.

The DOM Bottleneck

Imagine you're managing a library with 10,000 books, but your reading room only has 20 chairs. It would be wasteful to carry all 10,000 books into the reading room when patrons can only read 20 at once, right?

React faces the same problem with long lists. When you render a list of 5,000 items, React creates 5,000 DOM nodes—even though your viewport might only display 15-20 of them on screen. The browser must:

  • Create and store all 5,000 DOM elements in memory
  • Calculate styles and layout for every single element
  • Keep them ready for potential paint operations

Why This Hurts

The performance hit comes from two main sources:

  1. Initial render time: Creating thousands of DOM nodes is computationally expensive. Users experience noticeable lag during the first render.

  2. Memory overhead: Each DOM node consumes memory. With complex list items (images, nested components, event listeners), you might easily use 50-100 MB for a large list.

Even if items are "below the fold" and invisible, the browser still tracks them. Scrolling can feel janky because layout recalculations involve all nodes, not just visible ones.

The Reality Check

A list of 50 items? No problem. 500 items? Users might notice a slight delay. 5,000 items? Your app will feel sluggish, especially on mobile devices or older hardware.

Key Takeaway: Rendering thousands of DOM nodes creates performance bottlenecks regardless of visibility—React and the browser must manage every element, even those far off-screen.