Search This Blog

Checklist to Optimize a WordPress Website for Speed

The Story

I recently had to optimize a WordPress website, with a good amount of daily traffic, to load faster, since it was loading in about 1 - 1.5 minutes at rush-hours, and about 20 seconds on normal times.

I immediately thought that the website's slow performance would be due to lack of server resources: It's server may not have resources to handle the kind of traffic it was getting.

I was partially correct, but considering that the server was a dedicated one with 32GM RAM and an Intel Xeon processor, one can hardly say so.

Upon investigating the issue further, I found out that the website was configured to use as low as 64MB of RAM, even when it had 32GB, which is 200 times more than the latter. I instantly thought that the website administrator who set up it initially had either been too cheap with the amount of ram he would give to PHP, or been completely ignorant. I mean, even when you don't know what kind of traffic a website is going to get, if someone buys a dedicated server from you, it does suggest that their website may need more resources than what it is running on currently. If you plan, wisely, to leave the settings off to the person buying it, you should at least considering informing them once of their independence to configure the server to their liking.

Thus, I embarked on a journey to optimize this website, with 17 plugins installed. To my surprise, increasing the amount of memory that the website could use had little effect on the website's speed. However, that was a crucial step, since if the website has loads of visitors, and many plugins, things do need memory to run, you know.

The second thing I tried was disabling each plugin one by one, to check whether any one or more plugins were bad-coded and caused so much delay in server response. I did find out that a few of the plugins were actually the main culprits of the website's low speed.

Having removed those plugins, and having achieved some more speed in the website, I added caching functionality to the website. With HTML, CSS, JS caching and optimization applied, the website was now loading up a tad bit more quickly, or maybe I was just imagining it, but Google PageSpeed nevertheless ranked it much better.

The website was a long established one, so had so many images that optimizing them would be a pain. Nevertheless, I started optimizing the images. I couldn't use SSH to do it through the command line, so I had to use the Smush plugin to do about 50 images at a time, with WP-Admin open all the time. In fact, I'm still doing it.

The client flatly refused to add CDNs to make the website faster, saying that he had had a little chat with the server administrator, and they did not need CDNs at all. I was a bit surprised, but, owing to the fact that the server admin (assuming this was the same one) had not even considered increasing the memory available to the website, and that a putting down a CDN suggestion in place could hardly be termed as "ignorant", I was forced to assume that either the server admin was a very old fashioned guy, who hated CDN's or was a newbie who got scared of the client using a CDN, not knowing that what a CDN is.

Be as the case may be, I could not override the server admin, since he came first (haha), and therefore, I grudgingly crossed out CDNs from my optimization checklist for this website.

The website owner was happy by now, but I was not. The website still took 10-15 seconds to do a cold boot.

After researching a bit more, I found out about Opcache. Pre-compiled PHP code stored in caches! This could definitely give a WordPress website having 17+ plugins (I had installed a few more, by now) a speed boost.

I enabled Opcache and noticed a definite increase in performance. Now the website was loading under 10 seconds, with more than 2500 visitors on it.

Thus, I've prepared a handy checklist that I can follow every-time I need to optimise a WordPress website for speed.

The List

  1. Remove unneeded plugins
  2. Disable all plugins and enable each one by one to check which one is a bottleneck
  3. Increase PHP & WordPress memory limit
  4. Add opcache
  5. Minify & compress HTML, CSS & JS
  6. Combine CSS & JS files
  7. Compress all images
  8. Use a CDN for DNS as well as to serve static content
Don't forget to benchmark your website with a speed testing tool (I use Google PageSpeed and Google Chrome Network Console) before and after (and, possible, during) your optimizations.

Thank You

No comments:

Post a Comment