Troubleshooting guide
How to eliminate render-blocking resources
Browsers will not paint until they have finished the CSS and synchronous scripts in the head. Each of these adds to the time on a blank screen.
3 min read10 sectionsUpdated
On this page
Find them
Lighthouse lists these with their estimated saving. In the HTML, look for scripts in the head that have neither attribute, and for all stylesheets.
# Scripts with no async, defer or type=module
curl -s https://example.com/ | grep -oE '<script[^>]*src=[^>]*>' | grep -vE 'async|defer|type="module"' | cut -c1-120
# All stylesheets
curl -s https://example.com/ | grep -oE '<link[^>]*rel="stylesheet"[^>]*>' | cut -c1-120
# @import in CSS
curl -s https://example.com/main.css | grep -c '@import'Fixes
Add defer to scripts that depend on the DOM or on each other. Use async for independent ones such as analytics. Inline the small amount of CSS needed for above-the-fold content and load the rest asynchronously. Use media attributes so print CSS does not block. Replace @import with <link> tags. Use preconnect for critical origins, and self-host fonts where possible.
Async or defer?
Both download without blocking the parser. The difference is when they run. defer waits until parsing finishes and preserves document order, which makes it the safe choice for your own code. async runs as soon as the file arrives, interrupting parsing and in no fixed order, which is acceptable only for scripts that depend on nothing else. Modules are deferred by default. Do not put async on code that assumes another library has loaded, because it may pass in testing and fail randomly in production, depending on network timing.
Catch it automatically
A new tag added through a tag manager can undo this work without any code change. Real-user monitoring shows FCP and LCP regress by date, and a performance budget gives you a line that stops the drift.
Should all CSS be inlined?
No. Inline only what is critical; large inline CSS cannot be cached.
Does defer delay my script too much?
It runs just before DOMContentLoaded, which is suitable for most code.
Do preload hints remove blocking?
No. They fetch earlier, but a blocking resource still blocks.
Related reading
- AWS monitoring with CloudWatch metrics: Monitor AWS workloads: which CloudWatch metrics matter for EC2, RDS, ELB and SQS, the IAM permissions to read them and the alerts to set.
- What is Total Blocking Time (TBT)?: Total Blocking Time explained: long tasks, how TBT is calculated, the 200 ms target in Lighthouse, how it relates to INP and how to break up main-thread work.
- Gunicorn WORKER TIMEOUT: causes and how to fix it: Fix Gunicorn CRITICAL WORKER TIMEOUT: slow requests, blocked sync workers, memory pressure and the --timeout setting, plus which worker class to pick.
- How to monitor Render: How to monitor apps on Render: web service uptime and health checks, background workers, cron jobs with heartbeats, managed Postgres and Redis, and alerts.
- Java high CPU: how to find the thread with a thread dump: Find which Java thread causes high CPU: match top -H thread IDs against jstack output, read thread states, spot GC problems and use async-profiler safely.
- How to reduce Total Blocking Time (TBT): Reduce Total Blocking Time: find long tasks in the Performance panel, split JavaScript, yield to the main thread and defer third-party scripts until needed.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.