Eliminate Render-Blocking Resources With Async and Defer

News and Opinions

Updated on:

SEO & Link Building | Blogs & Websites

Photo of author
Written By Isabelle Merlin

Reviewed by: Isabelle Merlin

Why do we need to eliminate render-blocking resources? Render-blocking resources are static files, such ... Continue Reading Below

Why do we need to eliminate render-blocking resources? Render-blocking resources are static files, such as fonts, HTML, CSS, and JavaScript, vital to rendering a web page. When the browser encounters render-blocking resources, it stops downloading the rest until these critical files are processed. So the entire rendering process is put on hold.

On the other hand, non-render blocking resources don’t postpone the rendering of the page. After the initial page renders, the browser can safely download them in the background. Let's understand in detail below:

What are Render Blocking Resources?

Eliminate Render-Blocking Resources With Async and Defer
First Paint of Page – Eliminate Render-Blocking Resources With Async and Defer

The process in which the web resources (ex: JS, CSS & HTML files) that are loaded in the webpage potentially cause the browser to block the rendering of the page until they are loaded is called render-blocking resources. These web files can be large, with hundreds of kilobytes of data that must be loaded, in addition to the HTML, before it is rendered.

Therefore, always look for the best solution to eliminate render-blocking resources in above-the-fold content and optimize CSS delivery. Two techniques that are widely used are async & defer loading.

[quick_offer id=”15812″]

What is Render-blocking JavaScript?

JavaScripts that block the rendering of meaningful content are called ‘Render Blocking JavaScripts.’ They need to be either deferred or use async to eliminate render-blocking resources.

What are Critical and Non-Critical Java Scripts?

CRITICAL: JavaScripts files that are necessary to load during optimized critical rendering.

NON-CRITICAL: JavaScript files can wait to load until the web page's first meaningful content (the first paint) has loaded, called non-critical javascript.

What is Inline Delivery?

Inline delivery refers to loading a resource (like JS, CSS) within the HTML code instead of calling/importing that separately.

How to Remove Render Blocking JavaScripts From Website?

To remove render-blocking JavaScript, developers must inline critical JavaScript and defer all non-critical JavaScript to eliminate render-blocking resources errors.

You may also like to read:

Common Things About Async and Defer

Both async and defer have one common thing. That is, downloading render-blocking javascript doesn’t block page rendering. So the visitors may read the webpage content & get acquainted with the webpage immediately.

Why Should We Defer Loading of JavaScripts?

When the web browser comes across a javascript, it executes the script before loading HTML, including the content users are looking for. It means that JavaScript is a primary culprit in slowing your website.

For a browser, executing JavaScript is a heavier task as it depends on the size of the javascript. Also, it takes more time than rendering the meaningful content (the first paint) of the webpage.

Eliminate Render-Blocking Resources With Async and Defer

Hence, JavaScript affects the critical rendering path and slows your site's page speed. Also, defer loading heavier tasks of JS execution so that essential rendering paths remain uninterrupted.

How to Identify Render-Blocking JavaScripts on Your Website?

Using site speed testing tools, you can quickly identify your website's render-blocking JavaScript(s). You can see the results below for this article when we have gone through the Google page speed test:

Eliminate Render-Blocking Resources With Async and Defer
This Page Results – Eliminate Render-Blocking Resources With Async and Defer

Several page speed testing tools are available to analyze a website for site speed and loading time. The most reliable and trusted tools for page speed testing are:

1. PageSpeed Insights by Google
2. GTmetrix
3. Pingdom Tools

Test your website using the above speed testing tools and analyze the results of these tools to compare the results before and after implementing defer parsing of JavaScript(s).

What Does Defer Mean in JavaScript?

Defer literally means ‘hold back’ or ‘delay.’ If you use the ‘defer’ attribute in <script> for parsing (loading) of JavaScript, JavaScript will execute only after the HTML parsing has finished. This helps to improve the speed of a webpage.

Do Async or Defer Attributes Have Any Effect on Inline Scripts?

No, both async and defer attributes don’t affect inline scripts.

What is Defer Parsing of JavaScript?

Usually, Googe Pagespeed Insights (PSI) or other site speed testing tools (GTMetrix, etc.) show a warning/error. Eliminate render-blocking Resources if your website loads JavaScript(s) that block your site's meaningful content (the first paint).

According to Google PageSpeed Insights (PSI) recommendations, your website should deliver critical JS inline and defer all non-critical JS to eliminate render-blocking resources.

Therefore, deferred parsing of JavaScript means JavaScript(s) should load only after the website's content has loaded to eliminate render-blocking resources errors.

What's the Main Reason for Deferring Loading of JavaScript?

As you know,  the browser prioritizes executing the scripts over parsing the HTML. However, the fact is most of the JavaScripts are used only when the complete web page is loaded. Examples are animation, effect, some functionality, etc.

Therefore, loading JavaScript(s) only after loading the content is good.

Advantages of Deferred Loading of JavaScript

What is Defer Parsing?

Whenever a browser encoun­ters a javascript with the defer attribute, it sequentially follows the below steps.

  1. First, make par­al­lel requests to fetch the indi­vid­ual files.
  2. Meanwhile, Con­tinue pars­ing the doc­u­ment as if it was never interrupted.
  3. Then, Fin­ish task of pars­ing the web doc­u­ment even if the javascript files are downloaded.
  4. Once the parsing documents' task is finished, Exe­cute each script in the order they were encoun­tered in the document.


<script src=”myjavascriptfile1.js” defer></script>
<script src=”myjavascriptfile2.js” defer></script>

Therefore, Defer is very sim­i­lar to async attribute with just one major dif­fer­er­ence.

More interesting topics for you:

How Do You Defer JavaScript?

With HTML V5, two new boolean attributes for the <script> tag have been introduced. They are async and defer. The Async attribute allows the execution of javascript files asynchronously. But, the defer attribute allows execution only after the whole document has been parsed.

The webpage would have to load and execute scripts before rendering the page.

Here’s a usage example of defer attribute of <script>:

<script defer src=”/js/jquery.min.js”> </script>

How to Defer Loading of JavaScript in WordPress?

You can defer parsing of JavaScript in WordPress by following three methods:

  1. Using WordPress Plugins.
  2. Using the Script method (without using plugins).
  3. Adding a Code Snippet to the function.php file.

Advantages of Async Loading of JavaScript

How Do You Async Attribute in JavaScript?

When you add the async attribute to your script tag, the fol­low­ing steps likely will happen.

  1. It makes par­al­lel requests to fetch the files.
  2. It con­tinue parsing/loading the doc­u­ment as if it was never interrupted.
  3. Exe­cute the indi­vid­ual scripts the moment the Java files are downloaded.


<script src=”javascript1.js” async></script>

What is the difference Between Async and Defer Loading?

Async and defer are similar in allowing scripts to load without blocking the HTML parsing. It means users see page content more quickly. But they do have differences in eliminating render-blocking resources.

Here are the main difference between async and defer JavaScript.

1. The defer attribute delays JavaScript execution until HTML parsing has been completed. Whereas with the async attribute, HTML parsing & script execution happens simultaneously, and the script executes as soon as it’s ready.

2. Scripts loaded with async are parsed and executed immediately when downloading the resource. Scripts with defer attributee don’t execute until the HTML doc is parsed.

3. Async scripts may load out-of-order, but defer scripts are executed in the order they appear in the markup.

4. Async follows Load-first order. Here the order of documents doesn’t matter. It may load and execute while the document has not yet been fully downloaded. It also happens if scripts are small or cached and the document is long enough. Defer follows Document order (as they go in the document). It executes after the document is loaded and parsed (they wait if needed), right before DOM Content Loaded.

Plugins to Eliminate Render-Blocking JavaScript Easier

A few WordPress plugins can help you optimize your site by removing render-blocking JavaScript. In this section, we’ll look at all popular choices.

 WP Rocket

WP Rocket Eliminate Render-Blocking Resources With Async and Defer
WP Rocket – Eliminate Render-Blocking Resources With Async and Defer

WP Rocket helps with site optimization by minifying CSS and JavaScript, lazy loading images, deferring remote JavaScript requests, and more. It’s the ‘Swiss Army Knife’ of optimization plugins. 


Eliminate Render-Blocking Resources With Async and Defer
Autoptimize – Eliminate Render-Blocking Resources With Async and Defer

To eliminate render-blocking JavaScript and CSS in above-the-fold content from WordPress, you can use plugins such as Autoptimize. This plugin improves your WordPress site's load time by combining bits of code, making code blocks smaller by removing unnecessary characters (compression), and so on.

Making these changes makes the code easier to read and reduces the file size, thus shaving a few hundred milliseconds or even seconds off the loading time.

Access your WordPress dashboard and navigate to the Plugins tab to install this plugin. Then, select the Add New option on the window's upper side. Afterwards, you can look for Autoptimize or other plugins in the search bar. Click Install Now, activate it for the website you want, and you are ready.

W3 Total Cache

W3 Total Cache Eliminate Render-Blocking Resources With Async and Defer
W3 Total Cache – Eliminate Render-Blocking Resources With Async and Defer

What is interesting about this plugin is that it incorporates multiple extra features for optimizing WordPress. Caching represents storing specific files on a user’s computer to improve his website experience. Subsequence visits will be more accessible, and the load times will improve.

Key Features of W3 Total Cache:

  • Caching of (minified and compressed) CSS and JavaScript in memory, disk, or CDN.
  • Minify CSS, Minify JavaScript, and Minify HTML with granular control and minification of posts, pages, and RSS feeds.
  • Minify inline, embedded or 3rd party JavaScript with automated asset updates.
  • You can easily defer non-critical CSS and Javascript to render pages faster.
  • Defer offscreen images using Lazy Load to improve the user experience.
  • Browser caching using cache-control, future expire headers, and entity tags (ETag) with “cache-busting”.
  • JavaScript grouping by template (home page, post page, etc.) with embed location control.
  • Non-blocking JavaScript embedding and reverse proxy integration via Nginx or Varnish.

Speed Booster Pack

Speed Booster Eliminate Render-Blocking Resources With Async and Defer
Speed Booster – Eliminate Render-Blocking Resources With Async and Defer

Another option is Speed Booster Pack. Once you’ve installed it, you can access the settings and choose the options that suit your needs. The plugin offers configuration options like moving scripts to the footer or deferring JavaScript files from parsing. By selecting these, you can remove render-blocking JavaScript and CSS in above-the-fold content with just a few clicks.

With its ever-evolving codebase, Speed Booster Pack aims to increase your site performance, page load times, and PageSpeed (Lighthouse) scores! Optimocha, the company behind Speed Booster Pack, has a team with a pathological obsession for speed, so you can be sure your site will be in good hands.

JCH Optimize

JCH Eliminate Render-Blocking Resources With Async and Defer
JCH Optimize – Eliminate Render-Blocking Resources With Async and Defer

JCH Optimize is a plugin that combines JavaScript and CSS while reducing the files in size. It has many other features that can be useful in the long run, but it is excellent at eliminating render-blocking resources. Navigate its settings and activate the relevant features on your website.

Significant Features of JCH Optimize:

  • Page caching with optimized CSS, Javascript, and HTML.
  • GZip compresses the combined files and generates sprites to combine background images.
  • This plugin can exclude files from combining to resolve conflicts.
  • It will defer and load combined javascript files asynchronously.
  • You will get optimized CSS delivery to eliminate render-blocking.
  • CDN and cookie-less domain support and lazy load images.

Which is Better, Async or Defer?

While using an async attribute, the JavaScript file gets downloaded asynchronously & then executed as soon as it’s downloaded.

Whereas with the defer attribute, the file gets downloaded asynchronously. But executed only when the document loading is completed. Also, scripts will perform in the same order as they are called.

Assume we are using jQuery as well as other javascript that depend on it. We defer on them (jQuery included), making sure to call jQuery before the dependent scripts.

Eliminate Render-Blocking Resources With Async and Defer

Therefore, defer is the correct attribute choice when a script depends on another and defer is the right choice when async is not an option.

Why We Prefer to Defer Over Async?

Both async and defer cause JavaScript execution on the web page at different times to eliminate render-blocking resources.

Defer causes javascript execution to happen simultaneously as or later than async. It is because javascript is made defer or async & is less critical for the web page's important content. Therefore, it’s better to defer their execution outside of the primary rendering time.

Defer scripts can never block synchronous scripts. Whereas async scripts depend on how quickly they download. Synchronous scripts are typically made synchronous because they are essential for the web page's critical content.

Therefore, it’s always better to use defer attribute so synchronous scripts are not blocked from executing. Also, their critical work is completed more quickly.

FAQs About Eliminate Render-Blocking Resources With Async and Defer:

  1. Are images render blocking?

    Remember, images aren't rendered blocking, so if you have images on the blue DOM line, you can safely ignore those, although you will still want to optimize your images.

  2. What is CSS render-blocking JavaScript?

    Render-blocking JavaScript and CSS prevent a website from displaying a web page before loading these files.

  3. What is inline CSS?

    Inline CSS allows you to apply a unique style to one HTML element at a time. You assign CSS to a specific HTML element using the style attribute with any CSS properties defined within it.

Conclusion: Eliminate Render-Blocking Resources With Async and Defer:

So, we have discussed the best strategies to eliminate render-blocking resources.

To help visitors load the visible portion of your page more quickly, you should delay loading resources that aren’t immediately required.

Leave a Comment