awesome-everything RU
↑ Back to the climb

Browser & Frontend Runtime

Core Web Vitals: code and trace reading

Crux Read real markup, a click handler, and a web-vitals log line, predict the Core Web Vital that breaks, and pick the highest-leverage fix.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Vitals problems are diagnosed in markup, handlers, and the RUM log — not in a definition. Read each snippet, predict which vital breaks and why, then choose the fix a senior engineer makes first.

Goal

Practise the loop you run on every vitals regression: read the code or the attributed log line, predict which metric it hits, name the dominant phase or part, and reach for the fix that targets it — not the convenient one.

Snippet 1 — the un-sized hero

<!-- hero, the LCP element, injected after the article text -->
<section class="article">
  <p>Paragraph one of the article…</p>
  <img src="/hero.avif" class="hero" alt="Product hero" />
  <p>Paragraph two…</p>
</section>
.hero { width: 100%; }   /* height auto, no intrinsic ratio known */
Quiz

What breaks here, which vital does it hit, and what is the fix?

Snippet 2 — the lazy hero

<img
  src="/hero-2400.jpg"
  width="1200" height="800"
  loading="lazy"
  class="hero"
  alt="Product hero"
/>
Quiz

The dimensions are correct, so CLS is fine — but LCP regressed after this attribute was added. Which attribute, and why?

Snippet 3 — the click handler

button.addEventListener('click', () => {
  const filtered = hugeList.filter(matchesQuery);  // ~180 ms, 50k items
  renderResults(filtered);                          // re-renders the list
  highlightActiveTab();                             // tiny DOM update
});
Quiz

INP on this button is ~210 ms even though the thread is idle when the user taps. Which INP part dominates, and what is the highest-leverage fix?

Snippet 4 — the web-vitals log line

[LCP] value: 4120 ms  rating: poor
  element: img.hero
  url: /assets/hero-original.jpg  (3.8 MB, JPEG, 4000x3000)
  phase split: ttfb 280ms | loadDelay 90ms | loadTime 3510ms | renderDelay 240ms
[INP] value: 38 ms  rating: good
[CLS] value: 0.02  rating: good
Quiz

Reading this attributed RUM line, which fix is correct and what should you NOT do?

Recap

Every vitals regression is read in code or an attributed log: an img without width/height is a CLS shift; loading=‘lazy’ on the hero is a self-inflicted LCP load-delay regression; a heavy synchronous handler is INP processing time you move off the critical path with startTransition or scheduler.yield; and a web-vitals line’s phase split tells you which LCP phase to fix and which fix would be wasted. Read the attribution first, fix the dominant phase or part, then re-measure to confirm.

Continue the climb ↑Core Web Vitals: fix a failing article page
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.