Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 2 of 6 · Worked example · 25 min · revision 3

Diagnosing LCP: Images, Fonts and the Critical Path

Split a poor LCP into its four sub-parts, then fix the one that dominates: discovery and priority for the hero image, modern formats at the right size, and a font strategy that does not hold the page hostage.

Contentsand lesson path

What you will learn

  • Optimize loading with responsive modern-format images, font loading strategy, resource hints and fetch priority, HTTP caching and code splitting by route and interaction.

Prerequisites: How Browsers Render Pages

01. The problem: a storefront that paints late

The Estuary Fine Goods storefront from the lab lesson loads a page whose hero image is the largest element in the viewport — which makes it the LCP element. Under the lab's fixed throttling (the figures of Lighthouse's mobile profile, applied through DevTools) its median LCP is about 3.6 seconds: in the needs-improvement band (poor starts at 4.0 s). The stylesheet takes a deliberate 700 ms to arrive, the 466 KB, 2000-pixel hero is marked loading="lazy" with no width or height, and nothing in the markup tells the browser the image matters.

A slow LCP is not one problem; it is four, stacked end to end. The fix that works is the one aimed at the biggest slice, so start by splitting the wait into sub-parts and ranking them.

02. Step 1: split the wait into four sub-parts

LCP runs from the start of navigation to the frame where the element paints. The web-vitals attribution build reports the standard breakdown: the document's time to first byte, then — for an image element — the resource load delay (from first byte to the moment the image request starts), the resource load duration (the download itself) and finally the element render delay (from download complete to actually painted, usually held up by scripts or styles). The lab's dependency-free beacon reports the same four parts under shorter names (ttfb, loadDelay, loadDuration, renderDelay), and the baseline run on the slow storefront reads:

Illustrative output — LCP parts from one lab baseline run (machine-dependent)
LCP 3592 ms (last of three throttled lab runs)
ttfb             4 ms
loadDelay      911 ms   <- the image request starts late
loadDuration  2658 ms   <- 466 KB over a 1.6 Mbit/s link
renderDelay     19 ms

Read the largest bars first. Load duration, 2.6 s, is the download itself: a 466 KB file for a slot about 350 CSS pixels wide, over a slow link. Load delay, 0.9 s, is time in which the browser had not been told it needed the image: the request starts only after the 700 ms stylesheet has arrived and layout has shown that the lazy image is on screen. Time to first byte and render delay are tens of milliseconds, so a faster server or fewer scripts would barely move this LCP. Both large bars need work, and their fixes are independent — one is markup, the other is bytes — so the lab applies them in one edit. Lighthouse reports the discovery half as an audit: lcp-discovery-insight fires when the LCP image is lazy-loaded or cannot be found early in the HTML.

03. Step 2: make the browser discover the hero early

Three markup patterns delay discovery; this storefront uses the third, and its slow stylesheet makes it worse. An image inserted by JavaScript exists in no markup, so it cannot be requested until the script has run: in a measured comparison, the same hero requested from an onload script started downloading at ~236 ms, while an ordinary <img> in the HTML started at ~25 ms — the preload scanner reaches it while the document is still streaming. An image set as a CSS background-image is discovered only after the stylesheet has downloaded and the element's style is resolved. And loading="lazy" actively postpones the request until the browser has laid the page out.

The LCP image wants the opposite treatment: present in the HTML, never lazy, and explicitly prioritised with fetchpriority="high" so it wins the bandwidth race against scripts and below-the-fold images:

HTML · the LCP image, before and after
<!-- before: requested late, deprioritised, unknown size -->
<img src="../hero.png" loading="lazy" alt="Estuary at dusk">

<!-- after: in the markup, high priority, space reserved -->
<link rel="preload" as="image" href="../hero-800.png" fetchpriority="high">
<img src="../hero-800.png" width="800" height="560" fetchpriority="high"
     alt="Estuary at dusk">

The preload is optional here — the scanner finds an ordinary <img> quickly anyway — but it moves the request ahead of CSS and scripts when other work would otherwise win the queue; preload-responsive-images in the references shows how to pair imagesrcset with it. Do not preload more than one or two resources: everything you push forward pushes something else back. On the fixed storefront, where the lab also inlines the small stylesheet, the same beacon read loadDelay: 155 instead of 911: the request now starts as soon as the HTML arrives, not after the stylesheet and layout.

04. Step 3: send fewer bytes for the same picture

When the request starts early, the download duration becomes the bar that matters, and duration is bytes divided by bandwidth. The lab's hero is a synthetic PNG, so to see the format lever on a real picture, one 2000x1400 photograph was exported in four formats in a separate experiment; the sizes are the real files:

Same picture, four exports (bytes on disk, measured)
photo.png      9,915,852   lossless master: never ship this
photo.jpg        347,248   quality ~85
photo.webp       314,622   quality 70
photo.avif       209,527   crf 40
photo-800.jpg     12,315   right-sized for a 400 px slot

Two levers, both needed. The format lever swaps JPEG for AVIF or WebP and shrinks the same pixels by a third to a half. The size lever is bigger and cheaper. In the lab, the 2000-pixel hero fills a slot about 350 CSS pixels wide on a 1.75× screen, roughly 610 device pixels across, so about nine in ten of its pixels are thrown away. Serve a file close to the rendered slot with srcset and sizes — the responsive images lesson builds that markup in full — and keep width and height on the element so the space is reserved before the bytes land. In the lab, the 800-pixel export cut the file from 466 KB to 137 KB and the load duration from about 2.6 s to about 1 s under the same throttling. In the lab's Lighthouse stretch task, image-delivery-insight is the audit that should point at this waste on the slow page.

05. Step 4: fonts that do not hold the page hostage

Text is often the first thing that could paint, and a web font can delay or reshuffle it. Two mechanical facts drive the strategy. First, format: converting the DejaVu test face used in these experiments from TTF to WOFF2 took one command and cut the file from 757,076 to 256,924 bytes — and a subset of a real text face (the glyphs a site actually uses) is smaller again by an order of magnitude. Second, timing: a font requested from CSS starts late by default, so a font you truly need in the first paint should be preloaded with <link rel="preload" as="font" type="font/woff2" crossorigin>.

While the font is on its way, font-display decides what the visitor sees: swap shows the fallback immediately and switches when the face lands, block holds a short invisible period first, and optional gives up entirely if the font is not back almost at once. The honest caveat from testing these lessons: on the headless Chromium 156 build (from Playwright 1.64.1) used to verify these lessons, the block and swap pages both painted text before the 1.5-second font arrived, and the two screenshots were indistinguishable — so treat font-display behaviour as something to check on your target browsers rather than assume. What held everywhere: with the font delayed server-side, document.fonts finished loading at ~1.55 s while the page's first contentful paint was ~50 ms, and any late swap reflows text if the fallback metrics differ — size-adjust aligns them. The font best practices guide puts the whole strategy together.

06. Common mistakes

07. Check your understanding

Practice check · 3 questions

Ranking the sub-parts

Apply the breakdown to three cases.

Q1. A beacon reports LCP 2,900 ms as: first byte 150, load delay 60, load duration 140, render delay 2,550. The hero is already preloaded. Where do you look next?
Q2. The hero is a CSS `background-image` on a div, and a lab audit flags the LCP. Why?
Q3. A brand face is essential to the design, and you control the markup. Which combination keeps text readable while it loads?
Practice only: not graded, not saved, not evidence.

08. Apply it

Point the field-data beacon at a page you own, visit once, and write the four LCP sub-parts in a row. Then, in order:

  1. If load delay dominates: move the element into the HTML, remove loading="lazy", add fetchpriority="high", and preload only if other work still beats it in the network panel.
  2. If load duration dominates: export a right-sized modern-format image from the master, add srcset and sizes, and compare transferSize for the two loads.
  3. If render delay dominates: look for scripts or styles between first byte and paint using the unblocking lesson.
  4. Re-run the beacon and confirm the dominant slice moved — then re-check CLS did not grow.

09. Review prompt

Without looking back: name the four LCP sub-parts in order and say which one each of these fixes targets — fetchpriority="high", a smaller export, a faster origin, removing a script that runs before paint. Why does an image inside CSS or JavaScript start later than one in the HTML? What does preload change for an image and for a font? And why do width and height belong on the LCP image even after the bytes are fixed?

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check