Where LCP time goes

React chapter 143 · Web Perf · ch.2–3 · TTFB, FCP, LCP, latency, CDN, cache · source: initial load metrics, network conditions, CDN, repeat visits

The problem

The team spends a sprint making React render twice as fast and LCP barely moves. The server is in Norway, the users are in Australia: most of the 1.2 s is the server thinking and packets crossing the planet, not your components.

The pattern that fixes it

Draw the whole load waterfall first, then fix the biggest bar. High latency → CDN. Slow HTML → fix the server. Big JS on slow bandwidth → split the bundle. Only when JS + React is the biggest slice is React the thing to optimize.

In plain words

Before a page shows its main content, the browser waits for the server, downloads files, then runs JavaScript. LCP (Largest Contentful Paint) is the moment the biggest text or image appears. Speeding up the part that was 3% of the wait cannot make the page feel faster.

A pizza takes 60 minutes: 40 in traffic, 15 in the oven, 5 boxing it. Training the boxer to be twice as fast saves 2½ minutes. Opening a shop closer to the customer (a CDN) saves 30.

Terms

TTFB
Time To First Byte: from request to the first byte of HTML. Network latency + server think time.
latency (RTT)
How long one round trip takes, no matter how small the file. Distance, not bandwidth.
render-blocking
CSS in <head> and sync scripts. Nothing paints until they arrive. type="module" scripts are deferred.
LCP
Largest Contentful Paint. Good ≤ 2.5 s, poor > 4 s (at the 75th percentile of real users).

Going deeper

Why CSR makes LCP wait for JavaScript

A client-rendered app sends <div id="root"></div>. The browser can paint after CSS arrives, but there is nothing to paint until the JS downloads, evaluates and React renders. So in CSR, LCP ≈ TTFB + JS download + JS eval + render. Chapter 103 shows how SSR moves LCP earlier and what it costs.

Latency beats bandwidth

At 1 Gbps with 300 ms RTT the page is slower than at 10 Mbps with 40 ms RTT. Every request pays the round trip at least once (more with TLS and redirects). That is why a CDN — edge servers close to users — is step zero, before code splitting or Server Components.

Lab numbers vs field numbers

DevTools on your laptop is lab data: one device, one network. Google ranks with CrUX — real Chrome users, 75th percentile, 28-day window. Start with CrUX or RUM to find which pages are slow for real users, then reproduce locally with throttling (Performance panel → Network + CPU).

Repeat visits

Hashed file names (index-a1b2.js) + Cache-Control: max-age=31536000, immutable let returning users skip downloads entirely. Change one line and the hash changes, so the whole chunk is downloaded again — the reason splitting vendor code into its own chunk helps repeat visits (chapter 146).

Keep learning

Overview

Parse HTML CSS (blocking) JS bundle Eval JS React render My laptop 50 Mbps · 40 ms 3G · 10 Mbps · 300 ms Far server · 1 Gbps · 300 ms Main thread ts halo 60 || b.lane === 3 ? ( Server think time Network latency Downloading bytes JS eval + React Where the LCP time went Real life: servers in Norway, users in Australia. 1 Gbps internet — and 800 ms pass before the first byte of HTML arrives. A sprint of work, a rounding error on LCP. Pick an optimization and watch the green LCP line. The hatched bars — the server thinking and 300 ms round trips — are most of the picture. You optimized the thin green bar. Before touching code, look at how much of the bar is your code at all. Turn on Make React 2× faster. The green line moves ~30 ms of ~1.2 s. Add Halve the JS bundle. At 1 Gbps downloading was never the problem. Now look at the hatched bars. That is where the time is. Open the Solution. Fix the server: cache the HTML, kill duplicate permission checks, move work off the request path. Serve static files from a CDN, close to users. Then consider edge-rendering the HTML. Ship fewer bytes: split the bundle per route (100, 147), tree-shake (146), compress. Now React is the bottleneck: less JS to evaluate, SSR for first paint (103), fewer re-renders. server think time network latency downloading bytes Same page, any network. Find the biggest bar, fix that, repeat. The critical path of a client-rendered page The browser asks for HTML. It waits a round trip plus however long the server thinks. That is TTFB. Parsing the HTML reveals CSS and JS. Both start downloading. CSS in <head> is render-blocking. The JS bundle is usually the long pole: a round trip, then the bytes. Then the main thread parses and runs it. Only now can React create the DOM. In CSR the HTML was an empty <div>, so the largest content appears here: LCP. wins most when… latency of every static file users are far from your origin Faster server / cached HTML HTML is generated per request Smaller / split JS download + eval slow bandwidth, slow CPUs Faster React the green bar only everything else is already fast Long-cache hashed files users come back This page, measured by your browser p75 of real users On Far server, turn on CDN then Fast server. Two config changes beat any code change. Switch to 3G. Now downloading bytes wins — splitting the bundle is the right move here. On My laptop everything is green. That is why “works on my machine” says nothing about LCP.

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.