Performance · senior
List virtualisation
Virtualisation renders only the rows visible in the viewport (plus a small overscan) inside a container sized for the full list, so 10,000 rows cost about as much DOM as 20.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- The cost of 10k rows is the DOM size and layout, not React itself;
memoon rows does not fix it. - Math for fixed height:
start = floor(scrollTop / rowHeight),end = ceil((scrollTop + viewportHeight) / rowHeight) - 1, add overscan, clamp to the list; a spacer ofitemCount * rowHeightkeeps the scrollbar correct; visible rows are offset bystart * rowHeight. - Variable heights: estimate, measure rendered rows (ResizeObserver), cache measured sizes, and correct the scroll offset so content does not jump.
- Libraries: TanStack Virtual, react-window, react-virtuoso. In React Native, FlatList/FlashList do this.
- Combine with pagination or cursor-based infinite loading; keep the total DOM size bounded.
- Trade-offs: browser find-in-page cannot find unrendered rows, screen readers see fewer rows (use
aria-rowcount/aria-rowindexfor grids), SEO for server-rendered lists. - Lighter alternative for medium lists: CSS
content-visibility: autowithcontain-intrinsic-size.
The red pen
Common traps: mistake → fix
Mistake: "Just memo the rows"
Fix: the DOM is still huge.
Mistake: "Lazy-load the images and it is fixed"
Fix: the DOM and layout cost stay.
Mistake: "Virtualisation has no downsides"
Fix: find-in-page, accessibility and scroll restoration need work.
Easy to hard
Questions interviewers ask, easy to hard
- We render a 12,000-row table and scrolling stutters. What do you do?
- How does windowing work: overscan, spacer height, offsets?
- Rows have variable heights. Now what?
- What about Ctrl+F, accessibility and scroll restoration?
- Pagination vs infinite scroll vs virtualisation: when each?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.