Learn About The Web

Fix Render-Blocking CSS and JavaScript

Optimizing Wordpress Scripts

All WordPress plugins and themes will add CSS and JS files to your website front-end and these can cause your page to take longer to load as well as blocking page-rendering.

These files must be loaded by the user’s browser before the HTML can be loaded and those who have a poorer internet connection will have to wait even longer.

We call these stylesheets and scripts, ‘render-blocking CSS and JavaScript and this must be fixed if you are to attain a high Google Page Speed score. You are, after all, aiming for 100/100 and there are two ways that you can fix this render blocking.

Using Autoptimize

This is by far the easiest way and is a recommended method. First off, install the Autoptimize plugin through your WordPress dashboard and then activate it. Now you need to configure it.

Now use Google Page Speed to test your website speed again. If there are still any render-blocking scripts, go back to the settings page for Autoptimize.

Again, use Page Speed to test your website.

How it Works

Autoptimize works by aggregating all enqueued CSS and JavaScript and then creating minified JS and CSS files, lastly serving your website with cached copies.

Using W3 Total Cache

This is a slightly more complex method and is only recommended for those that already have W3 Total Cache enabled on their website. If you haven’t, and you want to use it, install the plugin on your dashboard.

The next step is to add the CSS and the JS that you need to be minified. The script and stylesheet URLs that are render-blocking can be found in the Page Speed tool.

Now go to Page Speed and test your website again, thoroughly, to ensure it all works OK.

Troubleshooting

You may find it quite hard to fix all the render blocking issues because it will depend entirely on how your theme and plugins use CSS and JavaScript.

While Page Speed and these two plugins can certainly help, the plugins might need specific scripts at another priority level if they are to work correctly.

If that is the case, these solutions may break the plugins or cause them to work in an odd way. Google might display specific issues, such as CSS Optimization for Above-the-Fold content. Autoptimize plugin gives the ability to manually fix that by enabling Inline CSS for displaying the area above the fold of your specific theme.

Tool Links

Here are links to the tools mentioned in this article.