learn.web Back to the curriculum ↗

HTML / CSS / JavaScript / 05

Performance is product design

Budget LCP, INP, and CLS; inspect the critical path; make expensive work visible.

Time
70 min
Mode
Learn → Make → Check
Path
Modern Web Platform

By the end, you can…

Performance is what waiting feels like

Largest Contentful Paint describes when the main content becomes visible. Interaction to Next Paint describes how quickly the page responds after a person acts. Cumulative Layout Shift describes visual stability. They are proxies for experiences—arrival, response, and trust—not trophies.

Field data matters because real devices, networks, caches, and interactions differ from a lab run. Use lab tools to diagnose a problem and real-user measurement to understand its prevalence.

Protect the main thread

A slow interaction often contains input delay, JavaScript execution, style and layout, then paint. Break up long tasks, avoid rendering work the user cannot see, defer noncritical scripts, and keep DOM changes focused.

Performance budgets turn intent into a constraint. Set budgets for page weight, third-party work, image dimensions, and interaction latency before the page grows expensive.

Working example
button.addEventListener("click", async () => {
  button.disabled = true;
  await scheduler.yield?.();
  renderOnlyWhatChanged();
  button.disabled = false;
});

Your studio task

Make — Measure one slow interaction and remove its largest block of main-thread work.

  1. Record one noticeably slow interaction.
  2. Name the largest blocking task and the user-visible delay it causes.
  3. Remove, defer, split, or reduce that work.
  4. Measure again under the same conditions and document the tradeoff.
Definition of done

You can explain which user-visible delay changed and why—not only quote a score.

Open the interactive lesson with its workspace ↗

Knowledge check

Which metric focuses on responsiveness after user interaction?
  1. LCP
  2. INP
  3. CLS
Reveal answer (B)

INP summarizes interaction responsiveness by measuring the latency of user interactions.

A long main-thread task most directly harms which experience?
  1. Interaction responsiveness
  2. First paint
  3. Page weight
Reveal answer (A)

Long tasks block the main thread and delay responses to user interaction, the INP experience.