Make the LCP image discoverable

React chapter 149 · Web Perf · LCP · preload, fetchPriority, responsive images, lazy loading · source: LCP discovery, eager loading, and responsive images

The problem

The hero is a 1.6 MB CSS background discovered late, then the team adds loading="lazy" to “optimize images.” The browser cannot request the LCP resource early, and a phone downloads desktop pixels it never displays.

The pattern that fixes it

Put the hero in the initial HTML when possible, keep it eager, give it fetchPriority="high", and serve a responsive candidate. Preload only when the critical image would otherwise be discovered late, and lazy-load the images below it.

In plain words

The browser cannot download an image it has not found. Help it find the one important image early, let it choose a file close to the displayed size, and postpone the images the user cannot see yet.

Tell the kitchen about the main course when the order arrives, not after the cutlery is laid. Bring one plate that fits the table; do not cook every dessert first.

Terms

resource load delay
Time from the first HTML byte until the browser starts fetching the LCP resource.
fetch priority
A hint that helps the browser choose which already-discovered request deserves bandwidth first.
responsive image
srcSet + sizes (or <picture>) lets the browser choose an image candidate for the layout and device.
preload
A <link rel="preload"> in the document head starts a known critical request before normal discovery would.

Going deeper

Discovery and priority are different levers

fetchPriority="high" cannot help before the browser discovers the image. A preload advances discovery; priority helps scheduling. An ordinary <img> in the initial HTML is already easy to discover, so measure before adding a redundant preload.

Never lazy-load the LCP candidate

loading="lazy" is valuable for offscreen gallery images because it removes them from the critical path. On the likely LCP image it deliberately delays the request. Keep the hero eager and reserve its dimensions so the image fix does not create CLS.

The preload must match the eventual request

Match the URL, destination, CORS mode, and responsive candidate. If the preload fetches one file and <img> chooses another, the browser may download both. Responsive preloads can use imagesrcset and imagesizes; verify the Network panel shows one image request.

Format is only half the image budget

AVIF or WebP can reduce bytes, but a 2800 px asset is still wasteful in a 390 px slot. Encode useful widths, describe the rendered size accurately, and inspect the chosen candidate and transferred bytes in DevTools.

Keep learning

Overview

image request ts halo tg halo Real life: a hero painted by CSS on a 4 Mbps phone. The team reaches for generic image advice. The LCP image phases Wait until discovery Queue behind other requests Download image Render delay found after CSS <img loading="lazy" src="/hero-2800.jpg" /> delays the LCP request Lazy loading made the hero later. Fewer bytes helped, but discovery is still late. The browser learns about the hero too late. Click Lazy-load the hero. The discovery marker moves right and LCP gets worse. Turn lazy loading off and click Send a 260 KB image. Download shrinks, but the CSS discovery delay remains. Open the Solution to move discovery, priority, and bytes independently. The HTML discovers the LCP image, high priority schedules it early, responsive candidates reduce bytes, and below-the-fold images are lazy loaded. HTML discovers img or preload high priority wins bandwidth right candidate 260 KB, not 1.6 MB paint hero Optimize the request path, not just the file. Treat LCP as four separate pieces: discovery delay, queueing, transfer, and render delay. A fast path for the hero image Put the hero in the initial HTML. If that is impossible, preload the exact image candidate from <head>. Use fetchPriority="high" for the likely LCP image. Do not mark a gallery full of images high priority. Use srcSet and sizes (or <picture>) so a phone does not receive desktop pixels. Keep the hero eager and reserve its dimensions. Use loading="lazy" on below-the-fold images instead. How the browser discovers the hero CSS background <img> in HTML Preload in <head> Image request priority Default priority High priority Transferred image 1.6 MB desktop file 260 KB candidate 4 Mbps mobile 20 Mbps Wi-Fi <link rel="preload" as="image" href="/hero-1280.avif" imagesrcset="/hero-640.avif 640w, /hero-1280.avif 1280w" <img src="/hero-1280.avif" width="1280" height="640" srcSet="/hero-640.avif 640w, /hero-1280.avif 1280w" sizes="100vw" loading="eager" fetchPriority="high" alt="…" /> <source type="image/avif" sizes="100vw" /> <img src="/hero-1280.jpg" width="1280" height="640" discoverable + reserved loading="eager" fetchPriority="high" alt="Developer at a desk" /> <img src="/gallery-7.avif" loading="lazy" alt="…" />

saved from the original path

The preferred path is simple: an eager responsive image in the initial HTML. Add preload only when measurement shows discovery is still late. Preload moved discovery earliest. Confirm it matches the candidate the image actually uses, or the browser may fetch twice. CSS still hides the URL until the stylesheet is available. Move the hero into HTML or preload the exact candidate. Choose CSS background, then change only priority. Priority cannot recover the time before discovery. Choose <img> in HTML + high priority. The request starts early without a special preload. Switch between the 1.6 MB and 260 KB candidates on both networks. Bytes matter most when bandwidth is scarce.

More courses

  • Jobs, linked to lessons — Browse jobs where every requirement links to the chapter that teaches it. See how ready you are, how long the gap takes to close, and which listings look stale.
  • Match a job post to courses — Paste a job post. Each skill is matched to a track here and put in learning order, foundations first.
  • Databases in depth — How a query becomes work. Indexes, isolation, locks, and the plans that explain why a page is slow — not an ORM tour.
  • System Design — Core concepts first (SQL vs NoSQL, CAP, indexing, replication, sharding), then designs grouped by what carries them: the database, Redis, Kafka, or many services.
  • NestJS: build a real API — One ticket-booking API, built in order: a plain Node server first, then NestJS modules, validation, a real database, and the features real clients lean on.
  • Microservices — Microservice patterns one diagram at a time: how to split a monolith, how services talk, and how data stays consistent without distributed transactions.
  • Kafka — A beginner-to-senior path through event logs, reliable delivery, production operations, and disaster recovery.
  • AI engineering for software engineers — Eight free reads, in order, for software engineers moving into AI: when to build an agent, how to build one, how to test it, and how the model works underneath.
  • Frontend system design — How a UI is sliced when it is a product, not a page: ownership of state, cache, routes, and what happens when the network lies.
  • TypeScript in depth — The type system as a design tool. Inference, narrowing, generics, and the errors that mean the model is wrong — not a catalog of utility types.
  • CSS in depth — See the box, then the page. Visual chapters from the box model through Flexbox surprises, Grid, selectors, and units, then backgrounds, shapes, and visual effects, each with a playground.
  • Accessibility — Foundations first (WCAG in plain words, semantic HTML, lists, alt text), then hands-on HTML labs, a full pass of WAI-ARIA 1.3, and a final fix-the-page challenge.
  • Docker — What an image is, why layers cache, and how containers find each other on a network.
  • Redis — Fifteen Redis patterns, one picture each: cache, session, lock, counter, rate limiter, queue, and when Redis is the wrong tool.
  • Kubernetes — Kubernetes from zero to operators: why it exists, Pods, Deployments and Services, then configuration, networking, storage, scheduling, scaling and security.
  • AWS — AWS networking in plain English. A VPC is a gated housing society: streets are subnets, the Internet Gateway is the main gate, and a route table is the signboard.
  • Networking: the NetRoute game — NetRoute is a packet logistics game. You wire up computers, switches, routers, firewalls and gateways, set each device, and watch glowing packets travel. If a packet gets dropped, the game shows you which header field was wrong.