
Render-blocking resources are CSS and JavaScript files that the browser must download and process before it can show anything on screen. Every stylesheet in the <head> blocks rendering, and every normal <script> without defer or async stops the HTML parser. To eliminate them, defer non-critical JavaScript, inline the small amount of CSS needed for the first screen and load the rest without blocking, remove unused CSS and JS, and self-host and preload fonts. This guide explains how the browser renders a page and gives the exact code for each fix. This guide explains how to eliminate render-blocking resources step by step.
- Add
deferto scripts that are not needed before the page appears. - Inline critical CSS for above-the-fold content; load the full stylesheet afterwards.
- Delete unused CSS and JavaScript instead of only deferring it.
- Fewer, smaller requests on the critical path improve First Contentful Paint and LCP.
Eliminate render-blocking resources: why CSS and JavaScript block rendering
The browser builds two trees: the DOM from HTML and the CSSOM from CSS. It cannot paint until both are ready for the visible content, because painting without styles would flash unstyled content. So every stylesheet linked in the head is render-blocking by default.
JavaScript is parser-blocking: when the parser meets a normal <script src>, it stops, downloads the file, waits for pending CSS, runs the script, then continues. On a slow mobile network each blocking file can add hundreds of milliseconds.
Eliminate render-blocking resources: how to find render-blocking files
- PageSpeed Insights / Lighthouse: the "Eliminate render-blocking resources" (or "Render-blocking requests") audit lists each file and the estimated saving.
- DevTools → Network: the "Render-blocking" column (enable it via right-click on the header) marks blocking requests.
- DevTools → Coverage (More tools): shows how much of each CSS and JS file is unused on the current page.
Fix 1: Use defer and async for scripts
| Attribute | Downloads | Runs | Use for |
|---|---|---|---|
| none | Blocks parsing | Immediately | Almost never in the head |
defer | In parallel | After HTML is parsed, in order | Your site scripts, menus, sliders |
async | In parallel | As soon as downloaded, any order | Independent scripts such as analytics |
type="module" | In parallel | Deferred by default | Modern ES module code |
<script src="/js/main.js" defer></script>
<script src="https://www.googletagmanager.com/gtag/js?id=G-XXXX" async></script>
Inline scripts that depend on a deferred library must also wait, for example by listening for DOMContentLoaded.
Fix 2: Inline critical CSS and load the rest later
Critical CSS is the small set of rules needed to style the first screen: header, hero, fonts and layout. Inline it in the head, then load the full stylesheet without blocking:
<style>
/* critical: header, hero, base typography (keep under ~14 KB) */
body{margin:0;font-family:Inter,Arial,sans-serif}
.hero{min-height:70vh;background:#101010;color:#fff}
</style>
<link rel="preload" href="/css/main.css" as="style"
>
<noscript><link rel="stylesheet" href="/css/main.css"></noscript>
Tools such as Critical (npm) generate critical CSS automatically, and WP Rocket, LiteSpeed Cache and other plugins offer "Remove unused CSS" or "Critical CSS" options. Always check the page for a flash of unstyled content after enabling them.
Fix 3: Use media attributes for conditional CSS
A stylesheet whose media does not match the current device is downloaded at low priority and does not block rendering:
<link rel="stylesheet" href="/css/print.css" media="print">
<link rel="stylesheet" href="/css/wide.css" media="(min-width: 1200px)">
Fix 4: Remove unused CSS and JavaScript
Deferring a 300 KB script still costs download and execution time. Removing it costs nothing. Common culprits:
- Full icon font libraries loaded for five icons. Use inline SVG instead.
- jQuery and jQuery Migrate loaded on a site that no longer needs them.
- Plugin assets loaded on every page, such as a contact form plugin's CSS on pages without forms. Asset managers like Perfmatters or Asset CleanUp can unload them per page.
- Page-builder CSS for widgets not used on the page.
Fix 5: Handle web fonts
- Self-host fonts as WOFF2 and preload the one or two files used above the fold.
- Use
font-display: swaporoptionalso text appears immediately. - Limit weights. Four weights of two families is eight files; most sites need three or four.
- If you must use Google Fonts, add
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>.
Fix 6: Move third-party tags out of the head
Chat widgets, heatmaps and pixels rarely need to run before the page appears. Load them with async, through Tag Manager, or after the first interaction. Every third-party domain also needs its own DNS lookup and TLS connection.
Eliminate render-blocking resources: what improves when you fix this
Removing render-blocking resources mainly improves First Contentful Paint and Largest Contentful Paint. See our guides to improving LCP and good page load times for targets.
Eliminate render-blocking resources: frequently asked questions
Eliminate render-blocking resources: can I defer all JavaScript?
Most of it, yes. Scripts that must run before paint, such as a small dark-mode or A/B test snippet, can stay inline in the head, but keep them tiny.
Is HTTP/2 a fix for render-blocking files?
HTTP/2 and HTTP/3 make many small requests cheaper, but files on the critical path still block rendering until they arrive.
Why did my site break after deferring scripts?
An inline script probably depends on a library (often jQuery) that now loads later. Exclude that library from deferral or move the inline code into a deferred file.
Related guides: Why Website Speed Matters and How to Make Your Site Faster, How to Get Your Website on Google and 301 vs 302 Redirects.
For official guidance, see web.dev by Google.
Need help?
Our performance team fixes render-blocking resources without breaking functionality. Contact us for a speed audit.
Written by the ItsWebExpert team, a web design and development company in Karachi building websites, online stores and apps for businesses across Pakistan.
Ask a Question on WhatsApp