How to Eliminate Render-Blocking Resources From Your WordPress Website

how-to-eliminate-render-blocking-resources-from-your-wordpress-website

Have you ever finished creating a WordPress website, loved everything about it, and promptly began to hate it after realizing it takes forever to load? Mastering the elimination of render-blocking resources will help diagnose this problem. But how?

Not only are slow loading speeds a nuisance for you and your visitors, but they can also cost you significantly when it comes to SEO. Since 2010, Google algorithms have accounted for loading speed in ranking decisions, so slow pages appear lower on results pages.

You might be familiar with the common culprits of poor page performance โ€” excessive content, uncompressed image files, insufficient hosting, and lack of caching to name a few. But thereโ€™s another often-overlooked perpetrator in play: render-blocking resources.

Grow Your Business With HubSpot's Tools for WordPress Websites

Donโ€™t get me wrong โ€” CSS and JavaScript are great. Without CSS, websites would be walls of plain text. Without Ja=ooovaScript, we wouldnโ€™t be able to add dynamic, interactive, engaging elements to our websites. But, if executed at the wrong time, both CSS and JavaScript can put a dent in your website performance.

Hereโ€™s why: When a web browser first loads a web page, it parses all the pageโ€™s HTML before displaying it onscreenย to a visitor. When the browser encounters a link to a CSS file, a JavaScript file, or an inline script (i.e., JavaScript code in the HTML document itself), it pauses the HTML parsing to fetch and execute the code, which slows everything down.

If youโ€™ve optimized your page performanceย in WordPress and are still experiencing problems, render-blocking resources may be the culprit. Sometimes this code is important to run on the first load, but much of the time it can be removed or pushed until the very end of the queue.

In this post, weโ€™ll show you how to eliminate this pesky code from your WordPress website and give your performance a boost.

If you’d rather follow along with a video, check out this walkthrough created by WP Casts:

1. Identify the render-blocking resources.

Before making any changes, you first need to locate the render-blocking resources. The best way to do this is with a free online speed test like Google’s PageSpeed Insights tool. Paste in your siteโ€™s URL and click Analyze.

When the scan is complete, Google assigns your website an aggregate speed score, from 0 (slowest) to 100 (fastest). A score in the 50 to 80 range is average, so youโ€™ll want to land in the upper part of this range or above it.

To identify render-blocking files that are slowing your page, scroll down to Opportunities, then open the Eliminate render-blocking resourcesย accordion.

the report from google pagespeed insights

Image Source

Youโ€™ll see a list of files slowing the โ€œfirst paintโ€ of your page โ€”ย these files affect the loading time of all content that appears in the browser window on the initial page load. This is also called โ€œabove-the-foldโ€ content.

Take note of any files ending with the extensions .css and .js, as these are the ones youโ€™ll want to focus on.

2. Eliminate the render-blocking resources manually or with a plugin.

Now that youโ€™ve identified the issue, there are two ways to go about fixing it in WordPress: manually, or with a plugin. Weโ€™ll cover the plugin solution first.

Several WordPress plugins can reduce the effect of render-blocking resources on WordPress websites. Iโ€™ll be covering two popular solutions, Autoptimize and W3 Total Cache.

How To Eliminate Render-Blocking Resources With the Autoptimize Plugin

Autoptimizeย is a free plugin that modifies your website files to deliver faster pages. Autoptimize works by aggregating files, minifying code (i.e., reducing file size by deleting redundant or unnecessary characters), and delaying the loading of render-blocking resources.

Since youโ€™re modifying the backend of your site, remember to use caution with this plugin or any similar plugin. To eliminate render-blocking resources with Autoptimize:

1. Install and activateย the Autoptimize plugin.

2. From your WordPress dashboard, select, Settings > Autoptimize.

3. Under JavaScript Options, check the box next to Optimize JavaScript code?.

4. If the box next to Aggregate JS-files?ย is checked, uncheck it.

the settings page in the autoptimize plugin

5. Under CSS Options, check the box next to Optimize CSS Code?.

6. If the box next to Aggregate CSS-files?ย is checked, uncheck it.

the settings page in the autoptimize plugin

7. At the bottom of the page, click Save Changesย and Empty Cache.

8. Scan your website with PageSpeed Insights and check for an improvement.

9. If PageSpeed Insights still reports render-blocking JavaScript files, return to Settings > Autoptimizeย and check the boxes next to Aggregate JS-files?ย and Aggregate CSS-files?. Then, click Save Changes and Empty Cacheย and scan again.

How To Eliminate Render-Blocking Resources With the W3 Total Cache Plugin

W3 Total Cacheย is a widely-used caching plugin that helps address laggy code. To eliminate render-blocking JavaScript with W3 Total Cache:

1. Install and activate the W3 Total Cache plugin.

2. A new Performanceย option will be added to your WordPress dashboard menu. Select Performance > General Settings.

3. In the Minifyย section, check the box next to Minify, then set Minify modeย to Manual.

the minify options section in the W3 Total Cache plugin

4. Click Save all settingsย at the bottom of the Minifyย section.

5. In the dashboard menu, select Performance > Minify.

6. In the JSย section next to JS minify settings, make sure the Enableย box is checked. Then, under Operations in areas, open the first Embed typeย dropdown and choose Non-blocking using โ€œdeferโ€.

the settings page in the w3 total cache plugin

7. Under JS file management, choose your active theme from the Themeย dropdown.

8. Refer back to your PageSpeed Insights results from your earlier scan. For each item under Eliminate render-blocking resourcesย ending in .js, click Add a script. Then, copy the full URL of the JavaScript resource from PageSpeed Insights and paste it into the File URIย field.

the settings page in the w3 total cache plugin

9. Once youโ€™ve pasted in all render-blocking JavaScript resources reported by PageSpeed Insights, click Save Settings & Purge Cachesย at the bottom of the JSย section.

10. In the CSSย section next to CSS minify settings, check the box next to CSS minify settingsย and make sure the Minify methodย is set to Combine & Minify.

the settings page in the w3 total cache plugin

11. Under CSS file management, choose your active theme from the Themeย dropdown.

12. For each item under Eliminate render-blocking resourcesย ending in .css in your PageSpeed Insights scan results, click Add a style sheet. Then, copy the full URL of the CSS resource from PageSpeed Insights and paste it into the File URIย field.

the settings page in the w3 total cache plugin

13. Once youโ€™ve pasted in all render-blocking CSS resources reported by PageSpeed Insights, click Save Settings & Purge Cachesย at the bottom of the CSSย section.

14. Scan your website with PageSpeed Insights and check for an improvement.

How to Eliminate Render-Blocking JavaScript Manually

Plugins can handle the backend work for you. Then again, plugins themselves are just more files added to your web server. If you want to limit these extra files, or if youโ€™d just rather handle the programming yourself, you can address the render-blocking JavaScript manually.

To do this, locate the