How to Boost WordPress Speed and Performance

Speed is everything. The web audience has an incredibly short attention span and Google uses your page loading speed as part of its SEO calculations.

Two compelling reasons to do everything you can to ensure your WordPress website loads as quickly as possible!

WordPress is fairly fast out of the box. It’s only when you begin adding themes, plugins, images, videos and all the engaging content to your site that it begins slowing down.

There is a way to have your cake and eat it though.

A way to have rich media on your website, use a beautiful theme and add lots of cool features with plugins. All while keeping page load times short.

This page will show you that way.

How to measure page load speed

Before we get into speeding up WordPress, we think it’s a good idea to run a speed test.

If you run one now and record the findings and another once you have completed the steps in this article, you have quantifiable evidence your website is faster.

We recommend using two tools to assess page load speed, Pagespeed Insights from Google and GTMetrix.

We’ll use GTMetrix for this example.

  1. Visit the GTMEtrix website and enter your website URL in the box
  2. Select the blue Test your site button and wait for the test to complete

When the test finishes, you’ll see a result like in the image above. It will give you a grade from A to G and a performance percentage.

The higher these results, the faster your pages.

There are a few useful metrics you can view in these results but we won’t get into them here as that’s an entire blog post in itself!

Suffice to say, we want to get from whatever your report says now to Grade A and a minimum of 95% for Performance. If we can get Structure over 90% too, all the better!

How to speed up WordPress

Speeding up WordPress is a process. The following includes a series of individual steps you can take to improve page load speed times. They work in isolation but all combine to create a faster website overall.

Not all of the steps will be relevant to you, so don’t worry about skipping them if you need to.

As long as you follow some of the steps, you’ll still improve the speed of your WordPress website!

A word of caution: While the majority of these methods work perfectly fine, every website is different.

If you run an ecommerce store or a very busy website, you may benefit from testing any changes on a staging site beforehand.

That way, should anything go wrong, you can roll back the change without impacting visitors.

Use a fast web host

The first tip we’ll share is to use a good quality web host.

Shared web hosting is cheap and the ideal way to start a website, but isn’t the fastest. You’re sharing that web server with hundreds, perhaps thousands of other websites, which has an impact on performance.

Upgrading to dedicated hosting, WordPress hosting, VPS or even dedicated cloud hosting can make a huge difference to the performance of your website.

It costs more, but it’s worth it once you build a following!

If your GTMetrix report shows a low score, check the Performance tab for:

  • First contentful paint – How quickly your browser receives the information it needs to create the first pixel of the page. The faster the better.
  • Speed index – How quickly the page becomes visible in the visitor’s browser. The faster the better.
  • Largest contentful paint – How quickly the browser loads the largest asset on the page (usually images). The faster the better.

These are all signs you might need a faster web host!

Keep WordPress updated

WordPress is constantly being developed and improved. Some of those improvements will include bug fixes, security updates and code refinements. All can speed up your WordPress site.

Plus, keeping WordPress updated is good practice!

Here’s how to do it.

  1. Log into WordPress select Dashboard from the left menu
  2. Select Updates
  3. Update WordPress if it notifies you of an available update
  4. Update any plugins if you see any that require it

The vast majority of WordPress and plugin updates work perfectly fine. But, if you run a particularly popular website or store, you may like to perform updates on a staging site before going live, just in case.

Use an optimized WordPress theme

Your WordPress theme makes your website look amazing but can have implications for page load time. If you use an inferior theme or an unoptimized one, it can slow down loading significantly.

Stylemix themes are all optimized for speed.

Not only do they look amazing and include all the interactivity you need, they are also designed to load quickly and require minimal resources!

Use a WordPress caching plugin

WordPress creates pages dynamically whenever a visitor lands on that page. This requires some processing and database calls to collect all the information to present to the user’s browser.

All that takes time.

A WordPress caching plugin takes a copy of the finished page and saves it in memory. Next time a visitor lands on the page, rather than building it from scratch, the plugin sends the copy to the visitor’s browser, speeding up the entire process.

A caching plugin can significantly speed up page load times.

WordPress caching plugins include:

There are lots of WordPress cache plugins around, read reviews and see which you like best.

Optimize your images

Websites need images to keep things interesting, highlight goods and services and help convert visitors. But unoptimized images are large files that can slow down page loading.

Optimized images are the answer.

If you saw a long ‘Largest contentful paint’ time on your GTMetrix report, you need to optimize your images. While the largest element can be anything, it is commonly an image.

Image optimization is a process of making the file sizes smaller without impacting image quality or the user experience. It might sound technical but there are specific plugins that can help.

We recommend optimizing your images before uploading to WordPress and then optimizing them further with a plugin.

You can use programs such as Mass Image Compressor on your computer to shrink files as much as possible. Simply crop the image to the correct size and run compression.

Then, once uploaded to WordPress, use a plugin like Smush to optimize them further.

By the end, you should have optimized your images to be as small as possible without compromising quality or the user experience.

Use a Content Delivery Network (CDN)

A Content Delivery Network is an excellent way to speed up page load times in WordPress, but can cost money.

A CDN takes a copy of your website and all its files and distributes it to CDN servers across the world. The idea is for the server closest to the visitor to provide the requested pages, which works out faster.

For example, if your web host is in Germany and your visitor is from Singapore, there is going to be a delay in page loading because of transmission time.

But, if you use a CDN with a server in Singapore, that server would send the pages to the user, which would be much faster.

Content Delivery Networks include:

Don’t host audio or video on your website

Rich media is an essential ingredient in engagement and every website should use it wherever possible.

However, while you should feature audio and video on your pages, you should not host it yourself.

You can upload audio and video directly to WordPress but it will cost you storage space and bandwidth. If you use a dedicated server, this won’t necessarily be a problem, but if you use shared hosting, it can be a problem.

You are better off using a service like YouTube, Vimeo, SoundCloud and others to actually host the video and embed it into your page.

That way, you get to use rich media but don’t have to worry about it slowing down your website!

Choose your plugins carefully

WordPress plugins add essential features to websites and we all make use of at least a few. But, like anything, quality is better than quantity.

That doesn’t mean only buying premium plugins because they are better, because they aren’t always faster.

It means choosing your plugins carefully, reading reviews and checking for complaints that the plugin slows down websites.

You could also test them on your staging website before uploading to live, just to make sure.

Minify CSS, HTML and JavaScript

Minifying is a term used to describe removing any unnecessary data from a file to make it smaller and more efficient.

That can include page breaks, unnecessary theme code, code to call elements not used within a WordPress theme and other useless junk.

Some caching plugins minify CSS, HTML, and JavaScript as part of the features but there are also plugins out there that can do the same thing.

Autoptimize is a very popular option for minifying as it’s free and very effective.

If you don’t want to use a plugin, you can use online tools to optimize and minify. Some options include CSS Minifier, JavaScript Minifier and Google’s own Closure Compiler.

Remove render-blocking JavaScript and CSS

Render-blocking JavaScript and CSS is code that stops pages being visible to the user.

You can see render-blocking JavaScript and CSS on the Waterfall tab of your GTMetrix report. It lists anything that slows down the loading sequence, including this code.

As a browser loads a page, it needs to process JavaScript and CSS before the page itself becomes visible.

The more code you have, the longer the delay in rendering the page.

The good news is, if you installed Autoptimize to minify your files, the plugin can also remove render-blocking files.

WP Rocket and some other caching plugins also have the option to remove render-blocking JavaScript and CSS.

Leverage browser caching

If you have used GTMetrix or Pagespeed Insights before, you’ll have seen a message to ‘Leverage browser caching’.

That has since been replaced with ‘Serve static assets with an efficient cache policy’ but it’s essentially the same thing.

Browser caching is a method of keeping a copy of your web pages on the visitor’s browser. So, if they visit again, the browser will immediately load its own copy, which improves the user experience.

It does this by adding Cache-Control Headers and ETag Headers to the visitor’s browser.

Cache-Control Headers tell the browser how long to keep the copy and ETag checks for any changes since that copy was taken.

To leverage browser caching, you’ll need to modify your .htaccess file or use a caching plugin.

Before proceeding, it makes sense to check if the caching plugin you installed earlier sets Cache-Control Headers and ETag Headers. WP Rocket does, other plugins may do the same.

The .htaccess file is used in Apache to control who can access your website and provide some basic rules for URLs and directory access.

If your host uses NGINX, you won’t have an .htaccess file. As most web hosts seem to use Apache, we’ll continue with that.

You’ll find your .htaccess file in your web host’s root folder. Take a copy of it before you make the change.

Then:

  1. Select your .htaccess file, right click and select Edit
  2. Paste the following to the bottom of the file before ‘# END WordPress’ and save once done

#Customize expires caching start


<IfModule mod_expires.c>
  FileETag MTime Size
  AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
  ExpiresActive On
  ExpiresByType text/html “access 600 seconds”
  ExpiresByType application/xhtml+xml “access 600 seconds”
  ExpiresByType text/css “access 1 month”
  ExpiresByType text/javascript “access 1 month”
  ExpiresByType text/x-javascript “access 1 month”
  ExpiresByType application/javascript “access 1 month”
  ExpiresByType application/x-javascript “access 1 month”
  ExpiresByType application/x-shockwave-flash “access 1 month”
  ExpiresByType application/pdf “access 1 month”
  ExpiresByType image/x-icon “access 1 year”
  ExpiresByType image/jpg “access 1 year” 
  ExpiresByType image/jpeg “access 1 year”
  ExpiresByType image/png “access 1 year”
  ExpiresByType image/gif “access 1 year”
  ExpiresDefault “access 1 month”
</IfModule>
#Expires caching end

You can change these settings to any period of time you like but we find these settings work fine.

Database optimization

WordPress is a database-driven content management system. The more data and tables in that database, the more searching WordPress has to do to find what it needs.

That’s where database optimization comes in.

If you know databases, there are lots of ways to optimize them. For us mere mortals, there’s WP-Optimize.

WP-Optimize is a free WordPress plugin that does all the hard work for you. It tidies up the database, optimizes tables and even optimizes your images too.

We would recommend taking a full backup of your site before you touch the database though, just in case!

Lazy-load long pages and posts in WordPress

Lazy loading images used to be essential for speeding up page load times. Did you know there’s an option for lazy loading long pages and posts too?

As WordPress now lazy loads images by default, it makes sense to set up lazy loading for pages and posts.

There are plugins for that, including WordPress Infinite Scroll and WP Ajax Load More Pagination, and Infinite Scroll.

Both make short work of lazy loading pages to provide a modest, but noticeable boost to page load times.

Use excerpts on your home page

We may be getting into the realm of marginal gains here, but every little helps. Like using excerpts of blog posts on your home page.

The default behaviour in WordPress is to show entire blog posts, which can slow down pages that feature multiple posts.

There’s a setting within WordPress that restricts this to excerpts, which load much faster.

If you feature your latest posts on your home page, you need to tweak this setting!

  1. Navigate to Settings and Reading in your WordPress menu
  2. Set ‘For each post in a feed, include’ to Excerpt
  3. Select Save Changes

This will not only make your page load faster but should keep things looking clean and tidy wherever you showcase your latest posts.

Limit comments per page

Limiting comments per page is another marginal gain, but one that can definitely impact speed if you get a lot of comments.

Rather than loading every comment ever made on a post or page, limiting them breaks them into pages. This reduces the processing required to render the page, which speeds up loading.

  1. Navigate to Settings and Discussion in your WordPress menu
  2. Check the box next to ‘Break comments into pages with’ and set the number of comments to 10-20
  3. Select Save Changes

You can set the number of comments to whatever you like. Obviously, the fewer comments you load, the faster the page, but you need to balance this with usability and encouraging comments on your posts.

Reduce redirects

A redirect is where a URL is redirected to another within a post or page.

For example, if you recently switched from using HTTP to HTTPS, you would use redirects to send visitors to the correct domain.

Redirects are used for all kinds of things and are an essential part of SEO and of usability. The more established and older your site is, the more redirects you are likely to have.

So how can you minimize them?

One way is to use a redirect within your .htaccess file.

In the example above, redirecting from HTTP to HTTPS can be done within WordPress but it’s more efficient to do it at the server level as it is much, much faster.

You’ll find your .htaccess file in your web host’s root folder. Take a copy of it before you make the change.

Then:

  1. Select your .htaccess file, right click and select Edit
  2. Paste the following to the bottom of the file before ‘# END WordPress’ and save once done

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 
</IfModule>

The code tells your Apache server to automatically redirect HTTP traffic to HTTPS, which saves WordPress having to do it and speeds up page load times.

Redirects are an extensive subject, so rather than bore you with it all here, why not read the Guide to WordPress Redirects over at WPEngine?

Reduce post revisions

The jury is still out on whether having multiple revisions of a page or post slows down your website or not.

It doesn’t hurt to reduce them though. If nothing else, it keeps your database tidy!

You’ll need to edit your wp-config file for this, which is in your WordPress directory.

  1. Right click wp-config and select Edit
  2. Paste the following code to the bottom of the file and save it

define( ‘WP_POST_REVISIONS’, 5 );

You can set any number of revisions you like, just change the ‘5’ to the desired number. Once the number of revisions exceeds this number, the database will drop the oldest revision.

Disable hotlinking

If you run a site that uses a lot of original images, you will quickly find people linking to your assets.

Rather than taking a screenshot of the asset or linking to the page, they will link directly to that asset so it appears on their page while still being hosted on yours.

This is called hotlinking.

All traffic, from your own visitors and from the site that hotlinked the page will use your website resources, which could slow down load times.

You can prevent it with another piece of code added to your .htaccess file.

  1. Select your .htaccess file, right click and select Edit
  2. Paste the following to the bottom of the file before ‘# END WordPress’ and save once done

#disable hotlinking of images

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourwebsiteURL.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

Just change where you see ‘yourwebsiteURL.com’ to your specific website URL and you’re good to go.

Speeding up WordPress

So that’s about it for speeding up WordPress.

Now is a good time to check your website speed in GTMetrix once more. If you implemented many of these steps, we bet you’ll now see a lot of improvement!

There’s a lot to take in and quite a few changes to make but we hope we have explained the why and the how enough for you to follow.

What you should end up with is a leaner, meaner, faster WordPress website. It should work exactly the same as it always has, but faster.

Do you have any other tips for speeding up WordPress? Followed this guide and want to share the results? Tell us in the comments below!

FURTHER READING