Render-blocking resources
Goal: the browser can paint the first screen after the HTML plus a small amount of critical CSS. Scripts never block parsing unless there is a documented reason.
Paths below are relative to this skill's folder (in Claude Code: ${CLAUDE_SKILL_DIR}).
When to use
- Lighthouse "Eliminate render-blocking resources" / "Render blocking requests" / "Avoid chaining critical requests" / network dependency tree
- High FCP, or LCP render delay dominates
- "White screen for 3 seconds", "should this script be async or defer?"
When not to use
- Fonts are the blocking resource:
web-font-loading - The page is a client-rendered SPA shell:
lcp-optimization(server rendering) - Too much JavaScript overall:
js-bundle-budget
Workflow
- Get the server HTML (what the preload scanner sees):
curl -sL https://example.com/ -o page.html - Run the scanner (read-only):
The "Critical path" list is every resource the first paint waits for, in order.python3 scripts/render_blocking.py page.html --base-url https://example.com/ python3 scripts/render_blocking.py page.html --json - Classify each blocking script (the decision table and snippets are in
references/patterns.md):
- independent (analytics, ads, widgets) ->
async, or load after consent/idle - needs the DOM or other scripts in order ->
defer(ortype="module", deferred by default) - must run before paint (theme/dark-mode flag, consent defaults) -> keep a tiny inline script, move everything else out
- jQuery dependents: deferring jQuery requires deferring every script that uses it and
replacing inline
$()calls. Test the page after this change.
- independent (analytics, ads, widgets) ->
- Fix CSS: replace
@importwith<link>, self-host third-party CSS that styles the first screen, load print/non-critical CSS non-blocking, and consider inlining critical CSS (~14 KB compressed) for the first screen when CSS is large. - Anti-flicker snippets (Optimizely, VWO, Google Optimize-style
async-hide): explain they hide the page for up to their timeout. Recommend removing them on pages without a running experiment, or server-side testing. This is a business decision: ask. - Resource hints:
preconnectfor 2-4 third-party origins used in the first seconds,dns-prefetchfor others. Remove hints for origins the page does not use. - Propose a diff of the
<head>and wait for confirmation; then verify by re-running the script and a Lighthouse run (FCP and "render blocking" savings should drop).
Output
Critical path: 12 resources (5 scripts, 7 stylesheets) before first paint
1. 4 sync scripts (emoji, jquery, jquery-migrate, slider) -> defer; jQuery-dependent inline code moved to DOMContentLoaded [high]
2. widget.js from cdn.widgets-example.net -> async + facade [high]
3. Anti-flicker snippet (4 s timeout) -> remove, no experiment is running (asked marketing) [medium]
4. Google Fonts + widget CSS (third-party) -> self-host fonts, widget CSS loaded on demand [medium]
5. @import extra.css inside <style> -> <link rel=stylesheet> [medium]
Expected: ~1.4 s faster FCP (Lighthouse estimate). Patch for header.php below.