KatInterview

Speeding Up a Cold Storefront Page and a 10M-Row Browser Table

System DesignModel answer
MediumModel answerSystem Designfrontend-performanceweb-vitalsvirtualization

Last updated

Audit and cut a 5-second cold-cache load on a retail landing page, then design a browser table that can browse 10 million API records without freezing or crashing.

Part 1: A slow first visit

A content-heavy retail landing page takes about 5 seconds to become usable when a visitor opens it in a private window with an empty cache. You are asked to bring that number down.

  • Describe how you would investigate where the time goes before changing anything.
  • Explain how you would shorten the critical rendering path and prioritize resources.
  • Compare splitting JavaScript into chunks with preloading resources, and say when each one helps or hurts.

Part 2: Ten million rows in one table

A web app has to present 10 million records, retrieved from an API, in a single table.

  1. Explain what goes wrong if you fetch everything and render it directly into the DOM.
  2. Propose an architecture that lets users explore the data without crashing the tab or making the UI stutter.

Your answer should cover:

  • Memory limits of a browser tab running V8.
  • How virtualization (windowing) works and how you would build it.
  • Fetching strategy: offset pagination, infinite scroll, or cursor-based loading, with trade-offs.
  • How to keep the table accessible to keyboard and screen-reader users while rows are virtualized.

Also be ready to say briefly how JavaScript's single-threaded model and event loop affect both parts.

Hints

Hint 1

Start by measuring: split the 5 seconds into network time, first paint, and main-thread work, and find which phase dominates before choosing fixes.

Hint 2

For Part 1, think about what blocks painting (CSS, synchronous scripts), what the browser discovers late (hero image, fonts), and what keeps the main thread busy (bundle execution, hydration, third-party tags).

Hint 3

For Part 2, do the arithmetic: records times bytes per record for the heap, rows times cells for DOM nodes, and rows times row height for scroll height. Then design so that only a constant number of rows and a bounded cache ever exist at once.