on 31 Aug 2023, by Bogdan, in Blog, WordPress, Cloud, Guides
by Bogdan
Render-blocking resources are critical to the performance of your website and its infrastructure when it’s live. Removing them can supercharge your website's performance by speeding up page loading times, enhancing user interaction, stabilizing the site, boosting its SEO, and improving other core web vitals.
In this article, we’ll show you six methods to eliminate render-blocking resources and take your website to the next level. We’ll cover the following:
Let’s get started right now.
Render-blocking resources are site files, usually CSS and JavaScript, that prevent your web page’s content from loading quickly.
For starters, when a browser encounters these render-blocking resources, it temporarily stops loading the rest of your page until the browser processes these files. This pause puts the display of your web page on hold, leaving your site visitors staring at a blank page or a sparsely populated web page.
If you don’t fix this issue quickly, you might lose site visitors before they can get to see your page. We definitely don't want this for you. So, keep reading to find out how to get rid of these files.
Normally, the browser regards everything in the <head> section of the HTML page as render blocking. These files include:
Other examples of render-blocking resources include:
Usually, these resources take too long to load slowing down your site. First, let’s take a closer look at the rendering path that we’ll improve when we get rid of render-blocking resources.
The critical rendering path is like a step-by-step guide that your browser follows to display your page. This involves the browser requesting files such as HTML files, stylesheets, scripts, and embedded images needed to display your web page properly. Some of these files might slow down this process. These files are the render-blocking resources we talked about earlier.
Once all the render-blocking files are dealt with, the browser continues parsing the rest of your HTML files until it’s all done. After that, the browser organizes how your page should look (with some additional work). When this whole process is finished, your web page is painted on the screen as illustrated below.
(source: DBS Interactive)
Normally, this process should only take a few milliseconds if it’s optimized properly. In fact, Google suggests that your web page should load within the first 2 seconds. Our aim is to assist you improve your site’s performance by removing render-blocking resources that cause your page to load slowly.
In this section, we’ll provide you with some best practices you can follow to remove render-blocking resources effortlessly and improve your site’s performance.
Before you can decide what to do with render-blocking resources on your website, the first step is to identify them. The most efficient approach is to analyze your website using performance analysis tools like Google PageSpeed Insights.
Other notable options are Lighthouse, which is now part of Chrome DevTools, as well as GTmetrix and webpagetest.org. Both PageSpeed Insights and GTmetrix utilize the Lighthouse library, providing free web applications for evaluating page speed, Core Web Vitals, and other performance metrics.
To identify render-blocking files that are slowing your page, scroll down to Opportunities, then open the Eliminate render-blocking resources section.
It’s important that you pay attention to any files ending with the extensions .css and .js, as these are the ones you’ll want to focus on.
The next step you will take will be based entirely on your goals. If you've received a render-blocking resource warning, you should focus on eliminating these issues one by one. However, if you didn't receive such a warning, you can still apply some of the following techniques to improve your site’s speed.
Deferring non-essential resources means holding off on loading less important files on your website until the critical parts of your web page (the content visible without scrolling) have been shown.
This approach allows users to start interacting with your page sooner, while non-essential resources like third-party scripts, fonts, and images load in the background. This technique strikes a balance between delivering a responsive page and making sure that less important resources don't slow down the main user experience.
It's important to note that this approach has become more popular with the introduction of Core Web Vitals, as it improves the site's LCP scores (which measure the rendering time of the largest content element above the fold).
Tip: You can use online tools like the Critical Path CSS Generator or Addy Osmani's Critical Library to find critical CSS code automatically instead of doing it manually. These tools pull out the CSS rules that matter for the content visible above the fold.
Tools like purifyCSS can analyze your CSS code to identify selectors that are not being used, allowing you to safely remove them. This even includes CSS code from third-party libraries like Bootstrap or Tailwind.
To further optimize, you can utilize Google Chrome's Coverage tab in the Chrome DevTools. This feature helps you see which CSS rules and JavaScript functions were used during a specific page load. You can then remove the ones that weren't used.
Popular content management systems such as WordPress also have clean-up plugins that let you remove your unused CSS and JavaScript automatically.
Tip: For JavaScript, it’s a good idea to manually review and consider code splitting. This approach ensures that only the necessary code is loaded for each specific page. Smaller code bundles, often considered non-essential resources, are lazy-loaded after the main webpage is rendered.
Next, let’s focus on minifying your CSS and JavaScript files. Minification helps you clean up your code, making it lighter. It involves removing unnecessary/extra elements in your scripts and stylesheets — parts that don’t affect your code’s proper functioning. This process optimizes your code and speeds up the critical rendering path.
(Source: atatus.com)
If you prefer manual minification, consider these steps:
Important: If you choose the manual route, always test your minified code to ensure it doesn't interfere with your website's design and functionality.
Alternatively, you can use online tools like Minify, Minify Code, PostCSS, and CSS Minifier for assistance. Additionally, tools like Webpack and Parcel come with built-in minification features to help you clean and optimize your code.
The defer and async attributes are both used in the <script> tag to control how the browser handles JavaScript files within the <head> section of an HTML file.
The defer attribute instructs the browser to download the script while simultaneously parsing the HTML content. The deferred script only executes after the entire HTML file has been parsed. This ensures JavaScript doesn't block the display of your page. On the other hand, the async attribute allows the browser to download the script concurrently without blocking the ongoing HTML parsing.
Choosing between the defer and async attributes depends on the specific needs and the behavior you want to achieve for optimal page load performance and script execution. The defer attribute, for instance, is recommended when:
The async attribute is useful when you have third-party scripts that are hosted on a different domain, and you want to prevent them from blocking the page. Google Analytics, for example, often recommends adding the async attribute to support asynchronous loading in modern browsers.
CDNs don’t necessarily eliminate render-blocking resources per se. However, you can use them to improve page load speeds. CDNs excel at handling multiple requests simultaneously, allowing them to load multiple CSS and JavaScript in parallel from a server closest to the user. This significantly speeds up content delivery, regardless of the user’s location.
Besides, many CDNs enable browsers to continue rendering a page while quietly fetching non-critical resources in the background. Since CDNs cache resources in the browser, repeated downloads are reduced when users return to your site. This clever approach ensures that render-blocking resources don't stop the process of fetching preloaded resources.
The benefits of eliminating render-blocking resources include:
In this article, we’ve explored six methods to eliminate render-blocking resources. Following these strategies not only meet your user expectations but also provides a boost to your search engine rankings while significantly enhancing your site speed and site performance.
However, getting rid of stuff that slows your website is hard work, and there are even more tricks to uncover. If you’re looking to create blazingly fast and optimized websites with ease, look no further than Brizy.
Brizy is a no-code website builder that simplifies the challenging steps of optimizing a website to help you create fantastic websites that excel in all aspects of great websites. This page builder utilizes clean and efficient code that helps you build mobile-friendly, SEO-optimized sites with lightning-fast load speeds.
Brizy Cloud is built with a focus on delivering fast-loading and responsive websites. The platform employs various techniques and coding practices to minimize loading times, reduce server requests, eliminate render blockers and optimize website assets, resulting in better overall performance. This is crucial as faster-loading websites enhance user experience, improve search engine rankings, and increase user engagement.
Also, you can learn how Brizy Cloud improves your Google Speed Insights score (and not only GSI) by reading this blog post here
Amazing page loading speed
We've tested Agens, one of our pre-made designs that comes included with Brizy and these are the performance grades and page load times:
Click the scores above to verify our claims.
RESOURCES
Choose Roadmap for
You will be redirected to our external roadmap boards on Trello