Karachi, Pakistan Mon–Sat: 10AM–7PM PKT
Home Services
Design & Development
UI/UX Design Web Development WordPress Development Responsive Web Design Corporate Website Landing Pages / Microsites E-Commerce Solutions Mobile App Development
Marketing & Growth
SEO Services Content Marketing Social Media Marketing PPC / Google Ads Branding & Creative Speed & Performance
Hosting & Support
Web Hosting Maintenance & Support
Portfolio
Website Design Logo & Graphics
Clients About Blog Free Tools Get a Quote
SEO & Speed Guide

How to Eliminate Render-Blocking Resources (CSS and JavaScript)

Why CSS and JavaScript block rendering, and how to fix it with defer and async, critical CSS, media attributes, removing unused code and better font loading.

Eliminate render-blocking resources: browser waiting on CSS and JavaScript files before rendering

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.

Key takeaways
  • Add defer to 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

AttributeDownloadsRunsUse for
noneBlocks parsingImmediatelyAlmost never in the head
deferIn parallelAfter HTML is parsed, in orderYour site scripts, menus, sliders
asyncIn parallelAs soon as downloaded, any orderIndependent scripts such as analytics
type="module"In parallelDeferred by defaultModern 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: swap or optional so 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

Let's Build Your
Next Website

Tell us what you need and we will reply within 24 hours with honest advice and a fixed quote.

Trusted by our clients, rated 5.0 on Google

5.0 11 Google reviews Read all →
I had a great experience working with Waqas and his team. We got some website development and SEO work done, and I'm quite satisfied with the overall results. They understood our requirements, suggested improvements, and handled the work professionally. What I appreciated most was their communication, attention to detail, and willingness to make changes whenever needed. Waqas is very cooperative, and the team knows what they're doing. Definitely a good choice for anyone looking for reliable web development and digital marketing services.
HUHafiz Ubaid Google review · Nov 2026
I was referred to their company by someone, and I'm really glad I connected with them. Waqas, the CEO, is a very humble and professional person who leads his team exceptionally well. Their expertise in digital marketing, web development, and custom development services is impressive. The team is skilled, responsive, and committed to delivering quality work. Had a really positive experience working with them. Highly recommended!
MRMuhammad Rafeeq Google review · Nov 2026
I had hired them for my client's task of Custom Wordpress plugin development. and many other tasks later on.. Waqas is super fast and sharp.. I know him since 2019.. I really really appreciate his work. Highly recommended..
RFRaheela Farooqui Google review · Nov 2026
I had a positive experience working with Waqas and his team. They provided excellent support with graphic design and social media management. The team was professional, responsive, and attentive to our needs. They understood our vision and delivered quality work on time. Highly recommended for anyone looking for creative and reliable digital services.
URUsman Rock Google review · Nov 2026
I really appreciate their dedication and professionalism. They have a good understanding of SEO, social media marketing, and online brand growth. Communication is smooth, and the quality of work is impressive. Definitely a great team to work with!
SSSameer Sarafaraz Google review · Nov 2026
I've had a great experience working with their team. They understand digital marketing very well and know how to improve online visibility through effective SEO and marketing strategies. Professional, responsive, and reliable. Highly recommended! 🙌❤️
MNMohammad naveed Google review · Nov 2026
I had a really good experience with web Experts. Everything was easy to understand, well-organized, and user-friendly. I appreciate the effort and attention to detail that has gone into creating this platform. It was a smooth and pleasant experience, and I would definitely recommend it to others. Keep up the great work!
SSShazia shaikh Google review · Nov 2026
Extremely professional and committed I am Extremely happy to work with them I wish them best of luck Best Regards M. Salman Farooqui
SFSalman Farooqui Google review · Nov 2026
Outstanding experience! Quality, professionalism, and customer service are all excellent. Keep up the great work!
ARabdul rehman Google review · Nov 2026
Excellent service and a great experience. The team is professional, helpful, and dedicated. Highly recommended!
MEmustafa emb Google review · Nov 2026