How to optimize your WordPress website

A well-optimized WordPress website is key to providing a great user experience, improving search engine rankings, and driving more traffic to your site. But with so many different factors that impact website performance, it can be difficult to know where to start. Whether you’re a beginner or a seasoned pro, this guide will walk you through the steps to optimize your WordPress website and get the most out of your online presence. From optimizing images and minimizing plugins to improving page speed and leveraging caching, we’ll cover everything you need to know to make your website fast, functional, and user-friendly. Read on how to optimize your website built on top of WordPress.

I will not be taking much of your time talking some gibberish, it will be short and sweet for every point I explain. So let’s get started.

Before we get started, I would stress to always backup your database and site contents (wp-content folder) on regular basis.

1- Use HTTP/2

We will start with HTTP/2. It is recommended to use HTTP/2 where ever possible. With HTTP/2 your website will be able to send multiple streams at one time compare to HTTP/1.1 where the requests wait for one another.

If you manage your own server and have Apache as web server serving your website with PHP. It is easy to setup HTTP/2. I recommend to use PHP FPM with Apache HTTP/2. What you need is php8.1-fpm package and then use h2 protocol in the Apache virtual host.

Check this guide where you will find all the important details for PHP FPM and Apache HTTP/2.

2- Optimize images

Large images can slow down your website, so it’s important to optimize images before uploading them to your website. There are different ways to do this. You can install images optimization plugin or just do it manually on your PC.

It is also recommended to use next generation images format like WebP. This will significantly reduce the image size.

You can use online tools to reduce the image sizes with TinyPNG.

3- Minification

Every websites lives on top of some JS and CSS resources. They are the bread and butter of a website. It is important to reduce their size and minify them as mush as possible. You can use online tools or some NodeJS packages from NPM to do the job for you.

4- CDN

Using a CDN will distribute your website’s static files across multiple servers, reducing the load on your server and improving website load times.

CDN is something a personal preference of a user. Some are fine with it and some may say, no I am out of it. In either case, if you would like to serve static contents of your website, it is good to use a CDN of your choice.

5- Compression

On the server side, use gzip/brotli compression. I would recommend to use brotli with Apache (if you are using Apache). It has much better compression rate compare to gzip.

6- Cache control

If you own the server, it is advised to set the cache header to a long time.

A sample Apache cache control header would look like below.

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
        Header set Cache-Control "max-age=63072000, public"

7- Cache plugin

Installing a caching plugin can significantly improve website speed by caching frequently accessed pages, reducing the number of database calls.

WordPress also recommend to use cache plugin. It won’t hurt, but to some adding an extra plugin could be daunting. There are many plugins available, your choice and mileage may vary. I recommend WP Super Cache.

8- Minimize plugins

Too many plugins can slow down your website, so it’s important to only use essential plugins and regularly remove any unused plugins.

Use only those plugins which you think your website need. Don’t keep unused plugins, just remove them, keep your website clean.

9- Theme

Choose a fast, lightweight theme for your WordPress website. Avoid themes with a lot of animations, graphics, and plugins as they can slow down your website.

If you are working on your own theme, it is advised to minimize extra and unnecessary code snippets, graphics, JS and CSS etc.

10- Lazy loading

Lazy load plugins only load images and videos when they are in the user’s view port, reducing the number of HTTP requests and improving website speed. Use a plugin which cater to reduce the requests when the page loads.

11- Database optimization

There are many ways to do this, for a start I would advise to reduce your posts/pages drafts to only 5 or less.

Second, use a database optimization plugin. Optimizing your database regularly can reduce its size and improve the website speed.

12- Updates

From time to time plugins and themes you use may get updates, regularly updating WordPress, plugins and themes can fix security vulnerabilities and improve website performance.

13- Check first byte

Check your website first byte. It is important to know how much time it takes when the first byte of your loads on user browser. Check your site here.

14- Performance check

You can check your site performance here to get the idea of how your website perform.

15- Site speed

This is very important for your website to keep your users keep coming. Always hit that high note on GTmetrix and Google page speed.

16- Site health

Always keep an eye on your site health from your Admin dashboard and fix what WordPress recommend on that page. You can find it under Tools -> Site Health on your WordPress Admin dashboard.

Hope these tips would make your website load faster. Here are a few extra tips which you can either apply or just skip.

  • Monitor your server resource usage
  • Use a security plugin