Front End System Design Playbook · Chapter 8 of 11

Performance deep dives

Almost every front end system design interview ends in an optimization deep dive, and performance is the most common one. Candidates often list techniques ("lazy load, memoize, use a CDN"). Strong candidates diagnose first, then prescribe, tying each technique to a user-visible metric and saying what it costs.

Frame performance with metrics

Use Core Web Vitals as the shared vocabulary:

MetricMeasures"Good" threshold (p75)Typical culprits
LCP (Largest Contentful Paint)Loading speed of main content≤ 2.5 sSlow TTFB, render-blocking JS/CSS, unoptimized hero image, client-only rendering
INP (Interaction to Next Paint)Responsiveness to input≤ 200 msLong tasks, heavy re-renders, synchronous work in handlers, hydration
CLS (Cumulative Layout Shift)Visual stability≤ 0.1Images without dimensions, late-loading ads/banners, font swaps

Supporting metrics: TTFB, FCP, Total Blocking Time (lab), JS bundle size, memory, and frame rate during scroll.

INP replaced FID as a Core Web Vital in March 2024. Mentioning INP rather than FID signals that your knowledge is current.

The deep-dive structure

For each topic, use symptom → cause → options → choice → cost → how to measure.

"On mid-range Android the feed scroll stutters (symptom). Each post renders rich media and we keep 500+ nodes mounted (cause). Options: virtualization, content-visibility: auto, or paginated DOM capping (options). I'd virtualize with measured heights (choice). This complicates scroll restoration, find-in-page, and a11y (cost). We'd track INP and long-animation-frame data via RUM (measure)."

1. Loading performance

JavaScript

  • Route-level code splitting with dynamic import() and React.lazy.
  • Component-level splitting for heavy, rarely used widgets (editors, charts, emoji pickers).
  • Tree-shaking-friendly imports. Avoid barrel files that pull in whole libraries.
  • Budget: e.g. ≤ 170 KB compressed JS for the critical path on mobile.
  • Ship less hydration: Server Components, islands, or partial hydration move work off the client.
const EmojiPicker = React.lazy(() => import('./EmojiPicker'));

function Composer() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <button onClick={() => setOpen(true)} aria-expanded={open}>Emoji</button>
      {open && (
        <Suspense fallback={<Spinner label="Loading emoji" />}>
          <EmojiPicker />
        </Suspense>
      )}
    </>
  );
}

Critical rendering path

  • Inline critical CSS or keep CSS small. Defer non-critical styles.
  • preconnect to API and CDN origins. preload the LCP image and key fonts.
  • fetchpriority="high" on the LCP image; loading="lazy" on below-the-fold images (never on the LCP image).
  • Fonts: font-display: swap or optional, subset fonts, and use size-adjust fallbacks to limit CLS.

Server and edge

  • Stream SSR so the shell paints before slow data arrives.
  • Cache HTML at the edge where personalization allows; split personalized fragments out.
  • Use HTTP/2 or HTTP/3, Brotli compression, and immutable caching for hashed assets.
  • Early hints (103) where supported.

2. Rendering and interaction performance

  • Break up long tasks: yield to the main thread (scheduler.yield() where available, or setTimeout chunking) during heavy work.
  • Mark non-urgent updates: useTransition / startTransition, useDeferredValue for expensive filtered lists.
  • Avoid unnecessary re-renders: colocate state, split contexts, use memoization (or rely on React Compiler where adopted).
  • Move work off the main thread: Web Workers for parsing, search indexing, diffing.
  • CSS containment: contain: content and content-visibility: auto let the browser skip work for offscreen content.
  • Animate only transform and opacity for compositor-friendly animations.

3. Large lists and tables

TechniqueWhenTrade-off
PaginationUsers need random access or countsLess fluid browsing
Infinite scroll plus DOM capFeedsMemory still grows unless you unmount old items
Virtualization (windowing)Thousands of rows, uniform or measurable heightsComplexity: variable heights, scroll restoration, find-in-page, screen readers
content-visibility: autoHundreds of complex itemsBrowser support and scrollbar jumpiness; set contain-intrinsic-size

For accessibility with virtualization: keep proper list semantics, use aria-setsize and aria-posinset for virtual items, and make sure keyboard focus doesn't get lost when an item unmounts.

4. Images and media

  • Serve modern formats (AVIF/WebP) via <picture> or an image CDN.
  • Use responsive srcset and sizes so phones don't download desktop images.
  • Always include width/height or aspect-ratio to prevent CLS.
  • Use blur-up or dominant-color placeholders for perceived speed.
  • Video: preload="metadata", poster images, adaptive streaming (HLS/DASH), autoplay only when muted and visible.
<img
  src="/img/hero-800.avif"
  srcset="/img/hero-400.avif 400w, /img/hero-800.avif 800w, /img/hero-1600.avif 1600w"
  sizes="(max-width: 600px) 100vw, 800px"
  width="800" height="450"
  fetchpriority="high"
  alt="Product hero"
/>

5. Network and data

  • Cache server state with stale-while-revalidate semantics.
  • Deduplicate requests: one in-flight request per cache key.
  • Prefetch on intent: hover, focus, or viewport entry for likely next routes.
  • Cancel stale requests with AbortController (autocomplete!).
  • Batch small requests, and keep payloads lean (field selection, compression).
  • Optimistic updates make interactions feel instant regardless of latency.
  • Service worker for offline support, asset caching, and background sync.

6. Perceived performance

What users perceive often matters more than what you measure:

  • Skeletons that match the final layout (and therefore don't shift).
  • Show content progressively: text first, then images.
  • Instant feedback on every interaction (pressed state within 100 ms).
  • Prioritize above-the-fold work; defer analytics and third-party scripts.

Measuring and guarding

StageToolPurpose
Local / labLighthouse, DevTools Performance panel, React ProfilerDiagnose
CILighthouse CI, bundle-size checks (size-limit)Prevent regressions
ProductionRUM via web-vitals library, Long Animation Frames APIReal-user truth by device and region
BusinessConversion, bounce, engagement correlated with vitalsJustify investment

Lab data finds causes. Field data (p75, segmented by device and network) tells you whether users actually benefit.

Matching deep dives to products

ProductMost important performance topic
News feedVirtualization, image optimization, SSR first page, prefetch next page
E-commerce PDPLCP hero image, SSR/ISR, third-party script control
ChatInitial conversation load, message list virtualization, real-time efficiency
AutocompleteDebounce, cancellation, caching by prefix, input responsiveness (INP)
DashboardData volume, Web Workers, chart rendering cost, incremental loading
Video streamingAdaptive bitrate, preloading strategy, startup time
Collaborative editorOperation batching, rendering only changed regions, worker-based merge

What lead candidates add

  • Budgets and ownership: "Each route has a JS and LCP budget enforced in CI; the owning team gets paged when p75 regresses."
  • Prioritization by impact: focus on the slowest real-user segment (e.g. low-end Android in India), not the fastest MacBook.
  • Business linkage: frame improvements in conversion or retention terms.
  • Org-wide levers: third-party script governance, shared image CDN, design system components that are fast by default.

Checklist

  • Framed the problem with a specific metric (LCP, INP, CLS)
  • Diagnosed the cause before prescribing
  • Gave at least two options with trade-offs
  • Covered measurement in the lab and in the field
  • Tied the deep dive to this product's most important user journey

Spotted a mistake or a rights concern? Report an issue