Learning how to make WordPress faster is an essential skill for every website owner. Website performance is a big part of usability and a sluggish site one of the best ways to drive away visitors and lose search rankings.
We have already published a detailed article on how to make your WordPress website faster. In it you learn why speed matters, what factors influence page load speed and what you can do to improve it.
In this article, we want to go a step further. Below, we have listed advanced techniques to improve the performance of your WordPress website. Some of them are built into WordPress and are relatively simple to implement, others are a little more technical.
However, all of them are effective and can improve the loading speed of your website. Therefore, if you want to take your site to the next level, keep reading.
Advanced Tactics for Speeding Up WordPress
Ready to make your site lightning fast? The techniques below will help you do so.
Use Excerpts Instead of Full Content
By default, WordPress will display the full content of your posts on the homepage and your archives. Depending on your content strategy, that’s a lot of material and takes a while to load.
A better idea, therefore, is to use excerpts — post teasers that show readers what to expect.
In WordPress, you have two ways to set these up. The first one is via the Read More tag, which you can find inside the WordPress editor.
If you place the cursor anywhere in your content and click the button, the post will automatically be cut off at that point.
This option gives you very much control, however, requires you to insert the link for every single post. For that reason, it might be more convenient to automate it.
To do so, go to Settings > Reading and find the option For each article in a feed, show.
Here, you can either choose Full text (the default) or Summary. When picking the latter, every one of your articles will automatically be cut off after 55 words. Of course, you can also control this number. Below is the code to do so.
// Change excerpt length to 120 words function change_excerpt_length($length) { return 120; } add_filter('excerpt_length', 'change_excerpt_length');
The downside of this approach is that you have no control where exactly the cutoff happens. It’s often in the middle of a sentence. You can avoid this by inputting custom excerpts in the WordPress editor screen.
Whatever you input in this box will appear on your front page as the excerpt for your post. If you can’t see it, enable it via Screen Options.
Divide Comments Into Pages
When you have a popular blog, you can get a lot of comments. In fact, some bloggers deal with literally hundreds of replies to their content.
While that is an awesome sign in terms of engagement, it adds a lot of extra data to your posts. Comments also need to be loaded, profile pics and all.
Unfortunately, the added time can make your most popular content less attractive for first comers. However, WordPress has a built-in solution for that.
Under Settings > Discussion, you can tell the CMS to break up comments into pages and also control how many it should display on each page.
Just check the box, pick your preferred settings, save and you are good to go.
Split Posts Into Pages
What works for comments, also works for posts. Dividing your articles into several pages especially makes sense if you regularly publish long, detailed and in-depth guides (which is a great content strategy) or long lists with many items and images. It makes things easier to consume for readers.
In addition to that, splitting posts is pretty easy to do. All you need to do is add the <!––nextpage––>
tag inside your content wherever you want it to divide. Note that you need to do this in text view, not in the visual editor. You can also add the tag more than once to create several pages from one post.
Add Lazy Loading
In case you don’t know, lazy loading is a technique that prevents images on a web page to be loaded all at once. Instead, it only displays images as they become visible on screen (such as when a user is scrolling down). Since images often make up the bulk of a web page, this can really cut down on your loading time. WordPress offers a bunch of lazy loading plugins to implement this.
Decrease HTTP Requests
HTTP requests are basically everything your browser needs to load in order to render your site. Requests can be internal and external, meaning either from your own site or an external resource. An internal request would be a theme stylesheet while a Facebook widget is an external one.
One of the easiest ways to reduce internal HTTP requests is to concatenate files. This simply means putting several files into one. That way, instead of having to load twelve different scripts with 15KB each, your browser just has to download one file with 180KB.
Since browsers have a limit of how many things they will download at once, this can save a lot of time.
If you are less technically inclined, can use the Autoptimize plugin to put concatenation into action. Developers can use a tool like Gulp to achieve the same or simply copy and paste manually.
A similar technique, but this time for images, is the use of CSS image sprites. Here, instead of files, you combine all images on a page into one. After that, you make them appear in the right place on your page by using background-position
. Again, this way the browser only has to load one large resource instead of many small ones. The technique is often used for social icons.
If you want to use sprites on your site, you can use tools like SpritePad and Stitches to create a spritesheet and the necessary CSS. CSS-Tricks also has an excellent guide on the topic.
Minify Files
Minification usually goes hand in hand with concatenating files. In fact, the aforementioned Autoptimize does both at the same time.
If you are not familiar with the term, minification means removing everything from your website files that is not necessary for machine consumption.
You see, we use a lot of formatting to make code legible for human beings. Comments, spaces, line breaks — everything to give code structure and make it look better. However, it also makes our files bigger. Thankfully, browsers don’t need any of that stuff. They are entirely satisfied with just one big blob of code. Consequently, we can use minification to make files smaller and faster to load.
In addition to the plugin solution on top, you can also use tools like Gulp or Grunt to achieve this. Brenda Barron has also written an entire blog post on this topic over at Elegant Themes.
Disable Hotlinking
If you create great content (as I’m sure you do), sooner or later someone will want a piece of it for themselves. Anything great published on the Internet will sooner or later be stolen, scraped and copied.
That’s just how it is. Don’t feel too bad about it. It happens to everyone and Google and other search engines are usually smart enough to figure out which article is the original.
The bad news, however, is that it can impact your site’s performance through a practice known as hotlinking. That is when someone imports images from your server via a link instead of copying them to their own site. That way, they will use part of your bandwidth without giving you any more traffic.
The good news: you can stop this from happening. Just add the following piece of code to your site’s .htaccess file:
#disable image hotlinking RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
Don’t forget to change mydomain.com to your actual domain.
Load Scripts Inside the Footer
To make a site appear faster, you can load important content first and non-essentials later. For example, a lot of scripts can be moved to the footer rather than the header of your site. When you do, the browser can start rendering the rest of the site before running them. Plus, it keeps your site from getting stuck in case one of the scripts is not running.
How can you do so? First of all, you should always load scripts using wp_enqueue_scripts()
. This function is made especially for this purpose and is the WordPress way to include scripts on your site.
As stated in the WordPress Codex, it takes several arguments:
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
Especially interesting for our purpose is $in_footer
. When set to true
(it’s set to false
by default), this will execute the enqueued script right before the closing </body>
tag instead of inside <head>
. Take this into account next time you add a script to your site.
Reduce and Optimize Database Queries
Unfortunately, some poorly coded WordPress themes ignore development best practices and make direct or unnecessary calls to the database. Like HTTP requests, database queries use up a lot of memory and can really slow down your server.
The solution here is to either decrease the number of queries or optimize the existing ones.
The first step to any of that is to figure out what kind of queries are running on your site. You can do so with Query Monitor. This might, for example, turn up plugins that put too much strain on the database (like the ones listed here). If that is the case, it’s time to replace those plugins.
In all other cases, try to avoid direct queries to the database. Instead, use one of the many available WordPress functions to achieve what you need. That’s what they are there for.
Also, while you are at it, optimize the database to make it run more smoothly and further speed up your WordPress website.
How to Make WordPress Faster in a Nutshell
A fast website is a must-have in today’s online world. Failing to optimize for speed is bad news for your bounce rate, conversions, SEO and overall success.
Thankfully, there is plenty you can do to make your site load quicker. Above, we have listed some advanced techniques to do so.
A number of them are standard features of WordPress that only need to be put into practice. However, there are also some technical measures to make your site faster.
You don’t have to do everything. Even if just put one or two of the above into practice, it will make a difference.
Besides that, it’s also important to remember that speed is not everything. While it is an important piece of the puzzle, there are a lot of other elements that make a website user-friendly. Therefore, don’t get caught up in the speed race but look how to improve your site as a whole.
Do you have any additional tips to make WordPress websites faster? If so, please share in the comments section below!
13 Comments