Slow websites are a nuisance. Visitors are quick to lose interest and hit the back button when a website is taking too long to load. According to Google, 53% of visitors on mobile devices will leave if a site takes more than three seconds to load. Additionally, search engines use the page loading speed as an indicator of how to rank a website, along with many other factors. If you want to get as much traffic as possible to your website, you should make sure it’s fast.

WordPress is a dynamic content management system (CMS), meaning that it generates a specific page once per page view. Although generating pages this way is not as efficient for static content as generating them once, it allows a lot of different kinds of dynamic content that are simply not possible with a static site generator. However, there are things you can do (like caching) that can keep your WordPress site running fast.

In this article, we’ll look at a variety of different ways to improve the performance of a WordPress site: caching, reducing redirects, lazy-loading images, using CDNs, and more.

How can I measure my website’s performance?

To be able to improve the load time of your website, you have to have a comprehensive suite of baseline measurements. Instead of manually testing your site with a variety of devices and internet connections, there are services that measure your site’s performance for you. GTMetrix and Pingdom Website Speed Test are both great free options. Once you’ve made the baseline measurements, you can make improvements to your website and measure how much they’ve made it faster.

How can I make my website faster?

1. Upgrade to the latest PHP version

WordPress is written in the PHP programming language. Because of that, any improvements made to PHP can make a noticeable improvement in the performance of your WordPress site. As PHP has matured, it’s gotten significantly faster and more memory-efficient. If you’re stuck on PHP 5, upgrading to the latest PHP version (which as of this writing is 7.4) offers you up to 100% faster performance and a 50% reduction in memory consumption.

2. Leverage server-side caching

Server-side caching is a way to prevent WordPress from needlessly rendering identical pages for every visitor. Instead of generating a new HTML file on every page load, a caching system will create one periodically and serve that file instead. By decreasing the amount of duplicate work, the server is taxed much less and can serve more visitors without an upgrade.

To implement server-side caching, try the WP Fastest Cache plugin. It makes using server-side caching as simple as enabling the plugin.

3. Use browser caching

Although they’re both referred to as “caching”, browser caching is different from server-side caching. In this version, the browser is instructed to keep a file around and not ask for a new version for a certain amount of time. Instead of reducing the time it takes to generate a page, browser caching will prevent images and other big files from being downloaded on every page load. Pages load faster on the second and subsequent page load because certain elements like images, stylesheets, and scripts are cached on the browser.

The easiest way to use browser caching is to configure your web-server to send the correct cache-control headers. Depending on the web-server you are using (Apache httpd, nginx, or others), the exact configuration will be different. For Apache, a common web server, the following configuration in your .htaccess file will cache images for 30 days and CSS and JS files for 7:

<filesMatch “.(ico|jpg|jpeg|png|gif)$”>

 Header set Cache-Control “max-age=2592000, public”

</filesMatch>

<filesMatch “.(css|js)$”>

 Header set Cache-Control “max-age=86400, public”

</filesMatch>

If your site is behind a CDN, you may also be able to configure these headers there (using Page Rules on Cloudflare, for example). If you use Apache and would like the .htaccess file configured for you, you can use this plugin.

4. Reduce HTTP redirects

Redirects are useful for preventing broken links to old content, but they make pages take longer to load. Every link on your website could potentially be a redirect, but it takes a long time to manually check all of them. Instead, use Dr. Link Check, which will find 301 and 302 redirects, not to mention broken links and other issues with links on your site.

5. Minify and compress HTML, CSS, JavaScript, and images

Even though text files containing HTML, CSS, and JS code might seem small, they add up quickly and can seriously slow down a website. In the case of images, you can significantly decrease their size by compressing them. Doing this manually would be a pain, so you can use a plugin like ShortPixel to automatically compress your images to an appropriate size. For HTML, stylesheets, and scripts, whitespace and other unnecessary content can be removed automatically through minification. The Asset CleanUp plugin not only minifies these files but also removes code associated with plugins that are unused on a certain page.

6. Use image lazy loading

Since many users leave before reading an entire page, loading images that are outside of their screen is wasteful. Lazy loading makes it so that only images that are visible or just about to be visible are loaded, decreasing bandwidth usage and resulting in a faster site. Although lazy loading is usually done through JavaScript, it can be configured with WordPress plugins like a3 Lazy Load. These plugins include the relevant JavaScript and make it easy to control the lazy loading through an admin interface.

7. Remove external resources

Fonts hosted through third-party web font services might be convenient and pretty, but they also can slow your site down noticeably if used excessively. Analytics scripts, embedded video players, and social media buttons are also culprits for the same reason. While each individual external resource might not make the site too much slower, together they can make a significant difference. You should take a look through the resources used on an average page on your website (using the developer tools in your browser) and determine which can be eliminated.

8. Deactivate/remove unnecessary plugins

One of the defining features of WordPress is its plugin infrastructure. It makes it very easy to add functionality through plugins instead of writing the functionality yourself. However, using too many plugins (especially poorly-optimized ones) can slow your website down considerably. Go through the list of plugins and figure out which can be removed or consolidated.

9. Offload static resources to a CDN

CDNs (content delivery networks) host static content (like images) closer to your users. This way, these large files will be downloaded more quickly and with less bandwidth usage on your origin server. There are a variety of different CDN services, but they usually fall into two categories: those that proxy your website through their servers, and those that you simply use for specific files. The proxy kinds can also handle HTTPS, DNSSEC, and otherwise act as a well-configured frontend server. Regardless of which kind you choose, using a CDN will make your pages load considerably faster for users everywhere.

10. Paginate comments

Pages with lots of comments require a lot of time to load at the server. If you head into Settings Discussions in WordPress, you can toggle on “Break comments into pages”, which should make your website load faster.

11. Enable HTTP/2

Depending on your web server (and/or CDN), the way that you enable HTTP/2 may be different. However, regardless of how you do it, turning this feature on can make a serious difference in your website’s load time. One of the primary features of HTTP/2 is that it can combine multiple files into a single request. Instead of needing an HTTP request for each file download (like scripts and stylesheets), HTTP/2 can combine those coming from a single server into one connection. This means that you don’t have to manually combine files together to achieve better load times. Additionally, HTTP/2 includes header compression, which makes HTTP headers smaller.

12. Upgrade your server or hosting package

If you’ve tried everything and simply can’t get your website to load fast enough, you might just need to upgrade your server. Before doing this, make sure that it’s actually the server itself that’s making your site slow. Are the physical resources (CPUs, RAM, and disk I/O) maxed out? When you do decide to upgrade, consider getting multiple servers in different places to better serve your users across the world.

Conclusion

WordPress can be difficult to make fast due to its nature as a dynamic CMS. That said, you can use a variety of tricks to make it quite a bit faster, from things as simple as upgrading PHP, turning on HTTP/2, and using cache directives to offloading assets to CDNs and lazy-loading your images. As you decide which to use on your website, make sure to constantly measure its performance to better figure out the effect of any given optimization.