What Blocks the First Paint and How to Unblock It
Diagnose a page that paints late, tell parser-blocking from render-blocking resources, and unblock the first paint with async and defer scripts and non-critical CSS loading.
Contentsand lesson path
On this page
- The problem: a page that paints late
- Step 1: measure the first paint and the blocking status
- Step 2: why these resources block
- Step 3: unblock the paint
- Step 4: choosing between async, defer and modules
- Check your understanding
- Apply it
- Review prompt
Lessons of How Browsers Render Pages
- From URL to Pixels: The Rendering Pipeline Concept · 25 min
- What Blocks the First Paint and How to Unblock It Worked example · 20 min
- The Main Thread, Long Tasks and Layout Thrashing Concept · 20 min
- Lab: Record and Read a Page-Load Trace Lab · 30 min
- Check: Annotate a Waterfall and a Flame Chart Knowledge check · 8 questions
What you will learn
- Identify render-blocking and parser-blocking resources and remove the blocking with defer, async or type=module scripts and non-critical CSS loading.
01. The problem: a page that paints late
A small site for a sourdough school loads far too slowly: the tab stays blank for the best part of a second before anything appears. The page itself is tiny — a heading, a paragraph, a link. Nothing on screen justifies the wait, which is exactly the signature of blocking resources: the browser has everything it needs to paint and is being prevented from painting. The head of the page looks like this:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bakehouse — Sourdough School (before)</title>
<link rel="stylesheet" href="/page.css">
<script src="/tag.js?ms=800"></script>
<link rel="stylesheet" href="/print.css?ms=700">
</head>Two of those requests are deliberately slow in our measurement fixture: the tag-manager script answers after 800 ms, and a print stylesheet after 700 ms. page.css is fast. Nothing here is exotic — a third-party tag manager and a forgotten print sheet are among the most common causes of a late first paint. The worked example below measures the page, explains why each resource blocks, fixes them, and measures again.
02. Step 1: measure the first paint and the blocking status
Load the page in Chrome or Edge, open the DevTools Console, and paste this snippet. It reads the first contentful paint (FCP) — the moment the first text or image reaches the screen — and asks every downloaded resource for its renderBlockingStatus, a property of Resource Timing that names exactly the resources the browser held the paint for. In November 2026 the property ships in Chromium-based browsers (Chrome and Edge 107 and later) and in Firefox 162, which is in beta until its planned December 2026 release; the current Firefox release and Safari print undefined for every resource, so there use the Network panel waterfall and the FCP marker instead:
const fcp = performance.getEntriesByName('first-contentful-paint')[0];
console.log('first contentful paint: ' + Math.round(fcp.startTime) + ' ms');
for (const entry of performance.getEntriesByType('resource')) {
const file = entry.name.split('/').pop();
console.log(file.padEnd(22) + entry.renderBlockingStatus);
}first contentful paint: 860 ms
page.css blocking
tag.js?ms=800 blocking
print.css?ms=700 blockingThere is the diagnosis in five lines: a page whose visible content needs no script and no print styles waited 860 ms, and the browser names the two resources it blamed. The Network panel tells the same story visually — the tag script and the print stylesheet appear as long bars in the waterfall while the page stays blank.
03. Step 2: why these resources block
Two different mechanisms are at work, and telling them apart matters because the fixes differ.
Parser-blocking. A classic <script src> with no attributes may call document.write, read elements that do not exist yet, or change the document while it is being parsed. The parser therefore stops at the tag until the script has been fetched and executed. Nothing after it — not even the body — is parsed, so there is nothing to paint. That is tag.js.
Render-blocking. The style stage needs the CSSOM to be complete before it can compute a correct first frame; otherwise users would see a flash of unstyled content, which browsers refuse to show. So the browser holds the paint until every stylesheet whose media query matches the current device has loaded. A stylesheet with no media attribute matches everything — including the screen — so print.css blocks the paint even though its rules would never be used on screen.
The glossary term for both is render blocking, and the web.dev lesson on the critical path works through the same chain: the fewer bytes and round trips between the navigation and a complete DOM plus CSSOM, the earlier the first paint.
04. Step 3: unblock the paint
The tag manager is independent of the page — no other script waits for it, and it does not need to run before the first paint. That is the textbook case for async: download in parallel, run as soon as it arrives, and pause the parser only while the script itself executes. The print stylesheet is only used for printing, so we declare that with media="print": the browser still downloads it (it will be ready when the user prints) but no longer counts it towards the first paint:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bakehouse — Sourdough School (after)</title>
<link rel="stylesheet" href="/page.css">
<script src="/tag.js?ms=800" async></script>
<link rel="stylesheet" href="/print.css?ms=700" media="print">
</head>The same console snippet against the fixed page:
first contentful paint: 28 ms
page.css blocking
tag.js?ms=800 non-blocking
print.css?ms=700 non-blockingThe first paint dropped from 860 ms to 28 ms — the cost of the fast stylesheet and the parse, with none of the tag manager's 800 ms and none of the print sheet's 700 ms. Note what did not change: in the Network panel the two slow downloads still take just as long as before. They run in parallel with everything else and finish late, but the page is long since visible. Unblocking does not make the network faster; it stops waiting for things the first frame does not need.
05. Step 4: choosing between async, defer and modules
Scripts have three non-blocking options, documented on the MDN <script> page. They differ in when the script runs, and getting that wrong breaks code that depends on order:
<!-- independent: run as soon as it arrives, order not guaranteed -->
<script src="/tag.js" async></script>
<!-- needs the parsed DOM, or another defer script: run after
parsing, in document order -->
<script src="/vendor.js" defer></script>
<script src="/app.js" defer></script>
<!-- module scripts are deferred by default, with imports resolved -->
<script type="module" src="/main.js"></script>Use async only for scripts that truly stand alone: analytics, ads, experiments. The moment one script needs another, or both touch the DOM, use defer, which preserves document order and waits for parsing to finish. A type="module" script is the modern default for application code: it is deferred like defer and resolves its imports for you. The application script in the lab later in this skill (Lab: Record and Read a Page-Load Trace) uses defer for exactly these reasons.
06. Check your understanding
07. Apply it
Take a page you control — or the slow page from the lab — and run the console snippet from step 1. For every resource marked blocking, decide which of the two mechanisms applies and write down the fix: async or defer for a script, a narrowed media for a stylesheet that does not need to match the screen, or a deliberate decision that the block is worth it (the main stylesheet of the page usually is). Apply the fixes, reload, and capture the before-and-after first-contentful-paint numbers — they are exactly the evidence the skill's practice task asks you to report.
08. Review prompt
Without looking back: state the difference between parser-blocking and render-blocking, and why a classic script in the head triggers the first while a stylesheet triggers the second. Then say when async is safe, when defer is the right choice, and what a module script does by default. Finally, explain why media="print" lets a stylesheet load without holding the first paint.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.