Break the render-blocking chain
React chapter 150 · Web Perf · FCP · render-blocking CSS, fonts, scripts, dependency chains · source: FCP, dependency chains, CSS, fonts, and deferred scripts
The problem
The HTML finds one stylesheet, that stylesheet imports a theme, the theme discovers a font, and a synchronous script pauses the parser. The files are not individually huge, but the browser must discover and finish them in sequence before useful pixels can appear.
The pattern that fixes it
Flatten the critical chain: link or bundle critical CSS directly, defer non-critical scripts, use font-display: swap, and postpone resources that do not affect the first screen. Inline only small, measured critical CSS; keep the rest cacheable.
In plain words
A render-blocking resource makes the browser wait before it can draw the page. The worst delays often come from one required file revealing the next required file, so fix the chain as well as the file size.
A painter cannot start while the color instructions are locked inside three nested envelopes. Put the essential instructions on the clipboard and deliver the decorations later.
Terms
- render blocking
- A resource or task that must finish before the browser can produce the next paint.
- CSSOM
- The browser’s parsed model of active CSS. It combines with the DOM to build the render tree.
- dependency chain
- Resource A must download before the browser can discover resource B, which then reveals resource C.
- parser blocking
- A classic synchronous script pauses HTML parsing while it downloads and executes.
Going deeper
CSS and fonts block different things
An active stylesheet blocks rendering because the browser needs the CSSOM to know what the page looks like. A web font usually blocks the affected text for a limited period rather than every pixel on the page. font-display: swap lets fallback text paint while the font loads.
Remove discovery chains before shaving milliseconds
A CSS @import, another imported stylesheet, and a font URL create serial discovery. Link critical styles from the document or let Vite bundle the imports so requests can start earlier. In DevTools, follow the Initiator chain and look for stair-step requests before FCP.
Choose the script behavior deliberately
A classic script without defer or async blocks the parser. defer downloads in parallel, runs after parsing, and preserves document order. Module scripts are deferred by default. async runs whenever its download finishes, so use it only for independent code whose execution order does not matter.
Critical CSS is a measured exception
Inlining a small amount of above-the-fold CSS can remove a request, but too much inflates every HTML response and cannot be cached separately. Extract only what the first screen needs, load the remaining stylesheet normally, and check both FCP and visual correctness.
Keep learning
- Previous: Make the LCP image discoverable
- Next: Choose preload or preconnect
- Related: lazy + preload
- Related: Request waterfalls
- Related: Yield to main
- Related: CSR blank vs SSR
- Related: React Compiler
- Related: Where LCP time goes
Overview
@import theme.css theme.css in parallel sync app.js defer app.js tg halo Real life: a styled React shell exists, but the browser cannot paint it while the head reveals one blocking dependency at a time. How to inspect the delay Order by dependency Order by file size Why first paint waits CSS discovery chain Font text block Synchronous script main.css · 22 KB theme.css · 18 KB brand.woff2 · 48 KB found only after main.css found after CSS <script src="/app.js"></script> pauses HTML parsing
First paint waits on a chain, not one giant file.
Sorting by file size hides the problem. Sort the Network waterfall by start time or follow each request’s Initiator to see who discovered whom. Click Order by file size. Every file looks modest, but the stair-step waterfall is still slow. Switch back to Order by dependency. The font cannot start until the CSS that mentions it arrives. Open the Solution and remove the three waits independently. HTML and CSS build the render tree, then layout and paint. Deferred JavaScript and non-critical assets do not hold the first paint. critical CSS render tree visible boxes size + position Anything required before this chain completes can delay FCP. Treat render blocking as a graph: keep only first-screen requirements on the path, then flatten their discovery. What must happen before the first paint The parser builds the DOM while the browser fetches directly linked critical CSS for the CSSOM. DOM + CSSOM become the render tree. Nested imports make this gate arrive late. Layout calculates geometry. Reserve image and component space now to avoid CLS later. The browser paints. Deferred scripts and non-critical assets may finish after these pixels exist. CSS discovery Nested @imports Direct / bundled CSS Application script Classic blocking script defer / module Web-font behavior Hide text while loading Paint fallback text <link rel="stylesheet" href="/critical.css"> discover from HTML <script type="module" src="/app.js"></script> modules defer by default fallback text can paint text waits
saved before first contentful paint
The CSS starts from HTML, JavaScript no longer pauses parsing, and text can paint with a fallback font. One or more serial gates remain. Change each control and watch which waterfall bar moves. Start with Nested @imports and change only the script. FCP still waits because CSS discovery remains serial. Flatten CSS but leave the font on Hide text. The stylesheet is ready, yet the affected text still waits. Use all three fixes, then confirm the real page with a throttled Network waterfall and an FCP marker.
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.