Skip to content

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

Key points

  • CSS is render-blocking by default.
  • defer keeps order and runs after parsing.
  • async runs as soon as it arrives, in any order.
  • Third-party tags are frequent offenders.

What render-blocking means

To avoid showing unstyled content, browsers wait for stylesheets before painting. A classic script in the head pauses HTML parsing while it downloads and runs. On a slow connection, a few of these files can add seconds.

Typical offenders

  • One huge site-wide stylesheet.
  • Synchronous analytics or tag-manager snippets.
  • Font CSS from a third-party origin, needing an extra connection.
  • @import in CSS, which delays discovery of files.
  • Framework bundles without defer.

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.

bash
# 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.

Frequently asked questions

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.

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.