Special Offer: My C#/.NET Bootcamp Course is out now. Get 10% OFF using the code FRIENDS10.

I am going to explain how I improved the page load performance of my WordPress blog by 50%. I achieved this by uninstalling unnecessary plugins, updating PHP to the newest version and migrating the comments from Disqus to WordPress built-in comments.

Notebook with improved performance charts

Uninstall unnecessary plugins

I went to the plugins page of my WordPress dashboard and went through every plugin currently installed and deactivated and deleted a few plugins.

When I set up my blog I thought that it would be good to have a few tiny plugins to customize my blog instead of fumbling with its source code on my own.

As a Software Engineer, I could have changed the themes and WordPress itself but I wanted to be able to use the convenient WordPress update mechanism. Therefore, I decided to use plugins to achieve whatever I wanted.

For example, I had a plugin in my widget (sidebar of the page) showing the most commented and most viewed blog post. Recently, I replaced this plugin with a simple custom HTML widget. I did the same for the social sharing icons in the sidebar and on top of the page.

Custom HTML widgets are lightweight and the code is encapsulated which means that I can still update WordPress and any installed theme and do not need to worry about my code being lost in the process.

By now, I prefer using a custom HTML widget over a plugin whenever possible. First of all, the resulting HTML can be cached and I have full control over how much additional CSS and other resources have to be loaded.

In the example above, the browser just needs to render a few more DOM elements, there are no additional stylesheets or images to load from the server.

Update PHP from version 5.6 to 7.2

Another thing I just recently realized is that my blog ran on PHP 5.6. I guess that this version is the last version my hoster automatically updated. In the meantime between setting up my blog and today, a few things have changed – even in the PHP world.

I quickly found out that WordPress seems to process up to 2-3x as fast on PHP 7.2 than on PHP 5.6. So I decided that I want to switch to PHP 7.2 for my blog.

Before I could switch to PHP 7.2 I had to make sure that my blog was compatible with it. WordPress itself in its newest version is fully compatible with PHP 7.2 but there might be some other code like themes or plugins which are not compatible with PHP 7.2.

Luckily (and ironically), there is a great WordPress plugin called PHP Compatibility Checker which can go over your particular setup and check everything for compatibility. It turned out I only had a single problematic plugin which was a syntax highlighting plugin.

After uninstalling the old and installing a more recent plugin (Enlighter) compatible with PHP 7.2 my blog was ready to run on the newest PHP version.

I want to mention that my hoster offers me to serve PHP 7.2 using either Apache or nginx. Apache can run using FPM or FastCGI. The only option that worked for my WordPress blog is Apache using FPM.

Migrated from Disqus to WordPress comments

Disqus is a widely used commenting system for WordPress and other platforms. It offers services like spam protection and single sign-on experience for your community. They recently introduced a new feature called reactions.

At the time I integrated Disqus into my blog (around 2013) it was the perfect fit for my needs. It kept the comments section clean, and it provided a much better user experience than the built-in WordPress commenting system.

A few years later things have changed. Disqus is no longer free. Or let’s say they show advertisements on your website. And believe me, they don’t look nice.

I was lucky to not have those advertisements yet. Or at least they did not show up when I was looking for them on my pages. I assume that I do not have enough traffic on my website or that Disqus does not have enough advertisers for the topics I write about. Anyway, I do not like any third-party tool or service being able to inject advertisements on my website.

Therefore, I imported all comments from Disqus into my local WordPress database and disabled and uninstalled the Disqus plugin from my blog. Performance wise it has a positive impact because my page does not require to load the additional Disqus files (CSS/JavaScript) and it does not load any advertisements on my blog.

I only have about 200 comments on my blog. My problem was that I have an article with more than 100 comments. I did not want to have all those comments loaded and rendered whenever a visitor accesses the page.

Luckily, there is a built-in option to break comments into pages. I split my comments into pages with 20 top level comments per page and show the last page with the most recent comments by default.

Wordpress Comments Settings

You can find the setting in your WordPress Dashboard in the Discussion sub-menu of the Settings menu. It is disabled per default which results in displaying all the comments below your blog post. I highly recommend enabling this feature if you care about the performance of your WordPress site (at least if you have more than ten comments on a single page).

Conclusion

I started with an average load time of about 6s on my test setup which included a first-time page access from Canada to my shared hosting in Switzerland and was measured starting with the DNS request and ending when the page is fully rendered. I used GtMetrix for my test.

After I changed everything highlighted in this blog post, the average load time decreased to about 3s with the same test setup. It is an improvement of about 50% without investing money, changing hardware or anything else.

If you’re running a WordPress website I highly encourage you to check if you can remove any unnecessary plugins and if you are running on the most recent PHP version.

Can you improve the loading time of your WordPress website as well? Do you have additional tips to share with me and other readers? Post your comments below.

Claudio Bernasconi

I'm an enthusiastic Software Engineer with a passion for teaching .NET development on YouTube, writing articles about my journey on my blog, and making people smile.