Speeding Up a WordPress Website

When it comes to building a successful website: Speed counts. Speed counts a lot. Google uses the performance of a website as one of its key factors for ranking a website. Therefore, if your website is slow, you may find yourself listed on page two or three for your most important keywords, rather than page one.

It is important to visitors too. KissMetrics reported that a whopping 40% of people abandon a website if it does not load within three seconds. They also found that a profitable eCommerce website making $100,000 per day would lose around $2,500,000 per year due to a one second delay.

It is not just large eCommerce websites that are affected. A drop in traffic will cause a decrease in advertising revenue and/or sales for any website. To put it more bluntly: No one can afford to have a slow website.

Today I would like to walk you through a tutorial on how you can improve the speed of your WordPress website. You do not need to be experienced in coding or managing websites in order to apply the majority of techniques detailed in this tutorial. All you have to do is follow best practices and apply simple techniques that will reduce your overall load.

Test the Speed of Your Website

The very first thing you need to do is test the speed of your website. This is an important step to perform before making any changes. The vast majority of speed benchmarking services are free to download. Additionally, they explain what is slowing down your website and detail exactly what you need to do to speed it up.

Google Page Insights

There are many great benchmarking services to choose from. I recommend testing your website with at least two services to get a better understanding of how quick (or slow) your website is. In my opinion, the top five benchmarking services are:

Benchmarking is something I encourage you to do directly after making any change to your website. This allows you to see how the speed of your website has improved or degraded after each modification.

Delete Unnecessary Plugins

Every WordPress plugin you add to your website slows it down. The load that some plugins add is negligible, however many plugins will slow down your website considerably. This could, in part be due to the advanced functionality that a plugin adds.

In general, the more functionality a plugin adds, the more it can slow down your website. You need to be aware of this when adding certain types of plugins such as galleries, backup plugins, member plugins, security plugins, stats plugins, SEO plugins and related posts plugins. Small plugins can also add a lot to your page load if they are badly coded or make too many calls to external services.

Many plugins have such a bad reputation for slowing down websites that managed hosting companies such as WP Engine have completely banned their customers from using dozens of particular plugins.

The good way to determine what plugins are slowing down your website is to install P3 Profiler. Designed by domain giants GoDaddy, the plugin displays the total load time of all your plugins. It breaks down exactly what each plugin adds to your page load. This allows you to see exactly what plugins are causing your website to be slow.

P3 Profiler

You can test the load of your plugins without using P3 Profiler. All you have to do is test the speed of your website using a speed benchmarking service. Then deactivate all of your plugins and test the speed of your website again. The difference in speed and page size is the load that your plugins are adding to your website.

Delete Unnecessary Plugins

Do not underestimate the damage that excessive plugins can do to your website. It is not uncommon for them to represent over 50% of a website’s page load. Be ruthless when you are reviewing your plugins. If a plugin is not essential, uninstall it.

Review Your Social Media Integration

Social media transformed the way that people share information online. Whether you use social media services regularly yourself or not; you need to give your visitors the opportunity to share your content. You will be missing out on a lot of social media traffic if you do not.

Official sharing buttons are very popular with website owners, perhaps in part because they show how many shares a particular page has had. This is because social proof helps generate more shares. That is, people are more inclined to share content if it has been shared by others. Therefore, if a visitor arrives at a page from a search engine, they are more likely to share the page via Facebook or Twitter if the article already has 100 shares than when it only has one or two shares.

Social Media Sharing Buttons

What many people do not realise is that official sharing buttons can slow down your website considerably. By simply adding Facebook, Twitter and Google+ to a page, you will add around 250 KB to its page size. That is a lot of weight to add to a page for three little buttons; and if you display these buttons above and below your content, that figure doubles. To see how much your own social media sharing buttons are slowing down your pages, deactivate or delete them temporarily and then test the speed of your website. Then add the sharing buttons back and do a speed test again.

This additional load is caused by the the Javascript code from Facebook, Google and Twitter making calls to their server. Calls to external servers always slow down your website. This is why many website owners have looked at alternative solutions such as loading Javascript code asynchronously. Socialite.js was a great example of this, however the script is unfortunately no longer developed.

If you want superfast sharing links on your website, the best thing to do is keep it simple. Replace those sharing buttons with text links and/or images that have been optimised for the internet. This eliminates the additional calls to external servers.

For many websites, official sharing buttons are a small price to pay for the additional traffic that they generate. However, if you are aiming to greatly reduce your page loading times, I suggest opting for a simple sharing solution that uses text links or small social media icons.

Review Your Hosting Set Up

You may have noticed that when you test the speed of one of your pages using a service such as Google PageSpeed Insights, the ranking of your page changes every time. This is usually due to the response time of your host.

Google recommend a server response time of 0.2 seconds (200ms) or better, however most website owners fail to achieve this. I tested my blog KevinMuldoon.com on PageSpeed Insights and the report stated that my your server responded in 0.71 seconds. I checked again immediately afterwards and it stated my server responded in 0.74 seconds. The third test showed a very poor 1.8 seconds response time.

WPHub.com showed a large disparity too. The first report stated that the server responded in 1.8 seconds and the second report taken directly afterwards reported a much improved 0.86 seconds. The third report showed an even better response time with the server responding in 0.54 seconds.

WordPress Hosting

There are many things that can affect server response time. A high number of slow database queries can contribute to a slow response time; however it frequently comes down to the quality of your host and your hosting package. Therefore, if your CPU and RAM allocation is not sufficient, your website may slow down considerably. A more costly scenario is using more than your allocated resources and seeing your website going offline completely.

Most hosting companies allow you to monitor your usage through the hosting control panel. You should therefore look closely at what you are using day to day and ensure your hosting plan can support it. For example, if your website uses 800 MB of RAM every day on average, it may be better to upgrade from a plan with 1 GB to a plan with 2 GB of RAM.

CPU Usage

If your CPU and memory is not bottlenecking and your server response time is slow; the blame could lie with your hosting company. Therefore, it may be in your interests to migrate to a better hosting company.

Reduce The Total Size of Your Images

Every image that is displayed on your page has to be downloaded by the visitor. This includes any background image, website logo, banners, photographs and any images within your content area. You can break down all these images into two areas: Your website design and your content.

Ideally, you want to be keeping images to a minimal within your website design as they will be used on every page of your website. Using an image for your logo, and possibly an image background, is OK. These images can be optimised too. You should, however, use CSS where possible. For example, rather than styling your header and footer using a large image, use can style it using CSS rounded corners.

The number of images used in your content affects your loading time too. Many online magazines use slideshows to present images so that only one image is displayed per page. This is usually a thinly disguised attempt to increase page views and indexed pages, rather than an attempt at reducing page size. Nevertheless, splitting images up into separate pages is a good solution that can be used with articles that have too many images.

In WordPress, this can be done by adding the following code within the content area:

<!--nextpage-->

When the above code has been added to an article, WordPress splits the content into many pages; with navigation links being added to the bottom of the article automatically.

Optimising images that are added to your articles is one of the best ways to reduce the page size of an article. The total size of your images may drop by more than 50% using optimisation techniques. Most modern graphical applications have an option for reducing the quality and size of an image for use on the web. For example, in Photoshop, images can be reduced using the “Save for Web & Devices” option.

You can then decide how much you want to reduce the file size by. Remember, the more you reduce the file size of an image, the more you reduce its quality. Therefore, you should try and get a good balance between file quality and size. I tend to save photographs as medium quality jpegs and all other images as 8-bit PNGs.

Optimise Your Images

Another service you will find useful is Smush.it from Yahoo. The service removes unnecessary bytes from image files; which reduces the overall size of an image. WordPress users can automatically smush their images using the plugin WP Smush.it. It is a great way to reduce the size of uploaded images, however you should be aware that the performance of your website can slow down a little whilst the plugin is working.

I have written many articles in the past that had hundreds of images listed in one article. One or two had more than one thousand images attached. These articles always prove to be very popular with readers, despite the article taking a long time to load. They also prove popular with search engines due to people linking to the article. In my opinion, even with the large page size, it is more practical for readers to read an article with many images in one page, rather than skip through hundreds of pages.

One way to do this successfully is to use a plugin such as Lazy Load. The plugin uses jQuery.sonar to load images on a page only when the user scrolls down to it. This allows the page to load quickly initially. Images out of view will then be downloaded one by one. It is a technique that many blogs have adopted.

Images can contribute a large part of your page file size. You should always be conscious of this when writing articles. I encourage you to get into a good habit of optimising the images you are uploading to articles. Even a small article with ten images can have its page size reduced by a few hundred kilobytes by simply optimising each image. Take advantage of WordPress’s in-built nextpage functionality and lazy loading too. Every little helps.

Optimise Your Database

Larger databases take longer to load. Your CPU and memory usage can therefore be decreased by reducing the size of your database. This will in turn improve your server response times.

There are a number of ways to do this. Firstly, you should keep your plugins to a minimum. I addressed this issue earlier in the article and focused on the page load a plugin can add to a page. What you may not realise is that plugins can also considerably increase the size of your database due to the number of additional tables they add. Frustratingly, some plugins leave these additional tables in your database even when you have uninstalled them. A great way of removing these unwanted tables is to install Plugins Garbage Collector. That will highlight tables that do not belong to any live plugins and allows you to delete them directly through the plugin (you should obviously backup your database before hand).

Optimise Your Database

Spam comments can also take up a lot of room in your database so you should always review your comment spam and then delete unwanted comments.

Do not underestimate how much your total database size can increase because of comment spam. One of my older websites suffered from spam badly. At one point it had over fifty thousand comments marked as spam. To store that data required over fifty thousand rows in the website database. On my personal blog, 1,695 comments currently takes up 1 MB of storage on my database, therefore I assume those spam comments on my other website added around 30 MB to my total database size.

A bigger problem is post and page revisions. The WordPress revisions feature makes WordPress store a record of each saved draft or published update. The autosave feature also stores one copy of your article. I am a big fan of this feature and it has saved me in the past when a newer copy was unintentionally modified. Unfortunately, this feature comes at a price. Those additional copies of your posts and pages take up a huge amount of storage space.

This week I am working on optimising my personal blog database for a book I am writing on WordPress optimisation. I have therefore turned my attention to the size of my database and the number of post revisions. My discovery astounded me.

KevinMuldoon.com is set up to save all post revisions. This is the default setting of WordPress and how most WordPress websites are configured. As a result of this, each post of mine has many post revisions. In total, my blog currently has 635 posts; of which 514 are published and 121 are drafts. Most of my drafts contain one or two lines of notes to remind me what to write about, therefore they will not have many post revisions. Nevertheless, it is better to include them in this calculation.

PHPMyAdmin confirms that my total database size is currently 172.90 MB. The posts table takes up 115.60 MB. This means that a whopping 67% of my filesize is due to posts and post revisions. The posts table has 9,911 rows. As noted above, the total number of posts on my blog including drafts is 635. This means that there is an average of 15.61 versions of every post saved in my database. Even for a user such as myself that does use revisions periodically; that figure is too high.

By simply disabling post revisions in WordPress, I could reduce the size of my posts table from 115.60 MB to only 7.41 MB. My overall database would drop to around a third of its previous size by doing this; going from 172.90 MB to only 64.71 MB.

The number of post revisions that WordPress saves can be configured by editing your wp-config.php configuration file. The default setting is to save all post revisions:

define( 'WP_POST_REVISIONS', true );

To disable post revisions, all you have to do is set WP_POST_REVISIONS to false and add the line below to your wp-config.php file:

define( 'WP_POST_REVISIONS', false );

Disabling post revisions is the most efficient way of keeping a small database, however it is not the most practical solution for authors. I believe you should at least keep a few revisions of each post until a post has been published.

To do this, all you have to do is define the number of revisions you want to keep:

define( 'WP_POST_REVISIONS', 3 );

If you do not want to control post revisions through your wp-config.php file, you can limit post revisions through a plugin such as Simple Revision Control. It allows you to define the number of revisions for posts, pages and custom post types.

MySQL databases can be optimised using the OPTIMIZE TABLE command through PHPMyAdmin (or directly through your admin area using a plugin such as Portable phpMyAdmin). This will reduce storage and improve the efficiency of your database tables. You can do this directly through WordPress using plugins such as Optimize Database after Deleting Revisions, TentBlogger Optimize WordPress Database and DB – Optimize.

The plugin Optimize Database after Deleting Revisions is a great option as it allows you to schedule your database to be optimised at certain times and days. It can also be used to delete spam comments and post revisions so is one of best all-in-one solutions for reducing the size of your database. You should also check out WP Clean Up. That details exactly how much storage things like revisions, drafts and spam comments are taking up; and gives you the option of deleting them all through your admin area.

It is very easy for small WordPress websites to slow down due to their database being overloaded with spam comments and unnecessary post revisions. I encourage you to stay on top of this or you may find your website slowing down over time.

Compress and Minify Your Code

There are a number of ways you can reduce the weight that your code adds to your page size. In this section, I would like to speak briefly about the most common ways to optimise your code.

My first recommendation is to compress your pages using gzip compression. Initially developed in 1992, gzip compression is hugely popular with website owners due to how much it can reduce your page size. Google advises that page sizes can be reduced by up to 70% using gzip compression.

Gzip is supported by all modern desktop and mobile browsers. It works by replacing common strings within your code with temporary strings. HTML frequently has lots of repeated whitespace and tags. This is why gzip works so great at reducing file sizes.

Once a browser has received the code, it will decompress it so that the visitor sees the page correctly.

Gzip Compression

There are number of ways to enable gzip compression on your website. Many caching plugins, such as W3 Total Cache, have an option for gzipping your files (more on caching later). A good dedicated plugin for gzip compression is WP HTTP Compression (note, at the time of writing, the plugin has not been updated since July 2012).

Alternatively, you can enable gzip by modifying your .htaccess file:

# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

If Zlib Compression Functions has been enabled in PHP, you can enable gzip compression by modifying the index.php file at the root of your WordPress installation:

ob_start('ob_gzhandler');
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/

Another interesting plugin to consider is WP-HTML-Compression. The plugin reduces page size by shortening URLs, removing comments and removing whitespace. Gzip compression is a better way of reducing page size, however you may want to try it out if you cannot use gzip compression for any reason.

Compress Your Code

Minifying CSS and Javascript files will also help reduce the size of your pages. Minify is a PHP5 application from Google that combines your CSS and Javascripts files. It also removes whitespace and commenting. Applying minify on your website will reduce bandwidth and HTTP requests from your server. Popular WordPress plugins that minify code are Autoptimize, Minify, Better WordPress Minify and WP Minify.

What many website owners do is minify their code before gzipping. An interesting service that explains the benefit of doing this is zBugs. When I tested WP Hub, it confirmed that CSS and Javascript take up a combined 171 Kb. Compressing this would reduce this to 164 Kb, however compressing and gzipping it would reduce it to only 36 Kb. That is a reduction of 135 kb; which represents a large reduction of 79% for CSS and Javascript files. This illustrates how important it is to minify and compress your code.

zBugs Results for WP Hub

Many caching plugins also let you minify and gzip your code. Therefore, if you choose to cache your content, you may want to do so through your caching plugin (I will discuss the benefits of caching later in this tutorial).

Review Your Comment Set Up

Third party commenting systems have become very popular over the last few years. I have tried many in the past myself such as Facebook commenting, LiveFyre, DISQUS and IntenseDebate. These services offer improved social media functionality and allow visitors to leave a comment using a wide range of services such as Facebook, Twitter, LinkedIn, Google and OpenID. They have become popular with large blogs such as Engadget due to this added functionality.

At the beginning of last year, Pingdom tested the speed of comment systems for blogs. They found that WordPress only added six files to a page whilst popular third party services Livefyre and DISQUS added nine.

Third Party Comment Systems Files Loaded

The WordPress commenting system was around 0.31 seconds faster than Livefyre and 0.47 seconds faster than DISQUS. Facebook was the slowest commenting system tested. It is worth noting, however, that Facebook does not sync all comments back to your database. Therefore, your total database size will be smaller if you use Facebook commenting as all comments will be hosted on an Facebook’s servers.

Third Party Commenting Systems Website Loading Speed Average

The test by Pingdom was performed eighteen months ago. I am unsure whether the test would provide the same results today. Perhaps LiveFyre or DISQUS have improved the speed of their service.

Let us assume that WordPress remains the fastest option for comments. Does that mean that we should all use WordPress’s comment system if we want to improve the speed of our websites? I am not so sure. I usually stick to the default WordPress commenting system myself, however I believe there are other factors to consider.

The reason that many turn to third party commenting services is due to the poor way that WordPress handles spam. At the moment, Akismet seems to be blocking most spam on my personal blog; however one of my other websites requires two anti-spam plugins installed in order to keep spam under control. As we have already established, your page loading time tends to increase as you install more plugins.

So whilst at first it appears that WordPress is by far the quickest solution for commenting, I believe it is best for you to review your complete setup. The most accurate way for you to test your quickest solution is to test the speed of your website using the default WordPress comment system together with any comment related plugins you are using; whether it be anti-spam plugins, a comment notifier for commenters or a plugin that allows visitors to login using social media services. This will give you a true representation of your complete comment setup.

Next, test the speed of your website using your preferred third-party commenting system. You can now see exactly what is the quickest solution for you and your website. As everyone enhances their comment area with different plugins, the solution that is best for me might not be best for you (and vice-versa). Therefore, comparing the speed of both setups is the only accurate way of seeing what is the quickest solution.

Use a Caching Plugin

Caching involves changing the dynamic files that WordPress produces into static HTML files. By using a caching plugin on your website you can drastically reduce the number of requests to your server and deliver your content to visitors quickly.

Setting up caching on a WordPress is easy as it can be configured using a plugin. There are a lot to choose from including DB Cache Reloaded Fix, Hyper Cache Extended and WP Fast Cache.

When it comes to choosing the best caching plugin for WordPress, the community is divided between two popular caching plugins: WP Super Cache and W3 Total Cache.

Use Caching Plugin

You will find hundreds of articles online that compare these two plugins and recommend one over the other. I do not recommend spending too much time sweating over which one to use. I have used both in the past and have been pleased with the results of both. They are both feature rich and work with all popular content delivery networks (more on that in the next section).

Most WordPress caching plugins also let you optimise your website in different ways. For example, W3 Total Cache supports minification and compression of HTML, Javascript and CSS files.

Caching is one of the best ways to reduce the number of requests from your server and speed up the delivery of your content. Some website owners argue that a caching plugin is not necessary if a website is optimised correctly, however I have always seen an improvement in speed after switching caching on. Without doubt, delivering static HTML files will always be quicker than making multiple requests to your server and database. Due to this decrease in load, caching might not only improve the speed of your website, it might also reduce your monthly hosting costs. Static files are also better at handling spikes in traffic, which is great news for anyone who is hoping for a spike in traffic from Digg, Twitter or Reddit.

Use a Content Delivery Network

Content delivery networks, sometimes referred to as CDNs, will improve the delivery speed of your website all over the world. Normally, a hosting company will be the only source of your content. So visitors will have to download it from that location from wherever they are in the world.

For example, my WordPress websites are hosted in Dallas, Texas, USA, and my discussion forums are hosted in the UK. Whenever someone visits one of my WordPress websites, they need to download my content from Dallas. The problem is that the further someone is away from a data centre, the longer it takes for them to download files. This leads to slower response times for people that live far from the data centre. This is where content delivery networks can help. They host a copy of your website in several places around the world. Visitors are then directed to a server that is close to them, giving them a speedier delivery of your content.

MaxCDN, one of the most popular CDN companies amongst WordPress users, state that if a website was hosted in New York, someone in England could see a response time of around 350 milliseconds. If a copy of the page was hosted through one their local servers instead, the response time would be as low as 24 milliseconds.

Content delivery networks charge customers by the amount of bandwidth that they use. For example, Amazon CloudFront CDN charge around $0.12 per gigabyte for the first ten terabyte of data every month. MaxCDN offer plans that allow a set amount of bandwidth. Their cheapest package, for example, starts at $9 per month for 100GB. This works out at around $0.09 per gigabyte of data. This is a little cheaper than Amazon’s pricing, however Amazon’s pricing gets cheaper as your bandwidth needs grows.

Content Delivery Network

Another content delivery network to consider is CloudFlare. In addition to being a fully functional content delivery network, they also offer security against comment spam, SQL injections, bots, email harvesters and more. CloudFlare are different to other CDNs in that they do not charge for bandwidth. Instead, they charge by the level of protection they offer. As you can imagine, their free plan is very popular, however their pro plan at $20 per month offers more security features.

WP Hub has been using cloudFlare for some time to offer faster content delivery to visitors all around the world.

CloudFlare

Content delivery networks can help you in many ways. First and foremost, you will improve the speed of your website across the globe. With CDN companies owning multiple data centres around the world, they are in a better position to handle traffic spikes due to their superior infrastructure.

Most content delivery networks charge for the bandwidth that you use. Due to your website and/or images being hosted on another server, your overall load and bandwidth usage with your hosting company will be significantly less. So whilst you may need to pay every month for content delivery, your total hosting costs could be lower.

Optimise the Mobile Version of Your Website

In June I spoke in-depth about The Pros & Cons of Responsive & Adaptive Designs. It is an issue that continues to split many website designers.

Google stated at the end of last year that they want people to use responsive designs so that every page on your website only has one URL. From an SEO perspective, using a responsive design that adapts to desktops, laptops, tablets and mobiles; seems like the best way to go.

From a user perspective, I can see the benefits of creating a unique experience for mobile users that caters to their needs. The added benefit of doing this is that it will greatly reduce your page loading time for mobile users. Speed remains a big problem for mobile users as most people have limited data plans with their mobile provider. The speed at which they can access the internet is much slower than accessing at home too. When a mobile user views a website using a responsive design, their mobile browser downloads the full size images that are used on the website and then scales them down for their mobile device.

An adaptive design resolves this issue by displaying your content using a minimal design. Many website owners see the size of their pages on mobile browsers drop from 1.5 MB to less than 100 KB by simply switching to a mobile design.

A few WordPress themes do come with adaptive designs specifically for mobiles, however my preferred mobile solution is WPtouch Mobile Plugin. Once activated, you will have a super fast mobile interface for your website that is supported by all modern mobile phones.

Mobile Version of Your Website

There are many factors to consider when choosing between a responsive or adaptive design for mobile users. You need to weigh all these factors up before making a decision. Without doubt, if your goal is to create the fastest experience for mobile users, you should use a minimal mobile design. I encourage you to read The Pros & Cons of Responsive & Adaptive Designs to get a full understanding of the pros and cons of doing this.

Other Techniques You Can Use to Speed Up Your Website

Up until this point, I have discussed the main methods that can be used to speed up your WordPress website. In this section I will cover some of the lesser known techniques and practices that website owners adopt to improve their website’s performance.

Reduce DNS lookup Time

Google notes that “Round-trip time (RTT) is the time it takes for a client to send a request and the server to send a response over the network, not including the time required for data transfer”. One of the best ways to reduce RTT delays is to minimise the number of DNS resolutions a browser has to make.

The best way to limit DNS-lookup latency from your application is to minimize the number of different DNS lookups that the client needs to make, especially lookups that delay the initial loading of the page. The way to do that is to minimize the number of different hostnames from which resources need to be downloaded. However, because there are benefits from using multiple hostnames to induce parallel downloads, this depends somewhat on the number of resources served per page. The optimal number is somewhere between 1 and 5 hosts (1 main host plus 4 hosts on which to parallelize cacheable resources). As a rule of thumb, you shouldn’t use more than 1 host for fewer than 6 resources; fewer than 2 resources on a single host is especially wasteful. It should never be necessary to use more than 5 hosts (not counting hosts serving resources over which you have no control, such as ads).

So according to Google, if you are using more than five different hostnames, your DNS lookup time may be unnecessarily higher than it should be. You should therefore reduce the number of calls to external Javascript and CSS files from your page.

Reduce 404s, Trackbacks and Pingbacks

404s are wasted requests to your server. It is therefore in your interests to keep 404 errors to a minimum. You can monitor your 404 errors through Google Webmaster Tools. The plugin Broken Link Checker can do this too. It highlights broken links and missing images and will send you an email when any are found. This allows you to address 404 errors as and when they occur.

Trackbacks and pingbacks also add additional requests for your server. They have long outlived their usefulness due to the sheer volume of trackback spam circulating. It is better to disable them altogether through the WordPress admin area (settings->discussion). This will reduce the requests to your server and reduce spam too.

Sprite Your Images

Spriting is the practice of combining all of your background and theme images and combining them into one sprite. This can reduce your image requests from over a dozen to only one or two.

One of the most popular resources for doing this is SpriteMe. The free service will group all your images into one sprite for you and provide you with the CSS code for inserting it into your website. You should also check out SpritePad (which is also free).

SpriteMe

Spriting is a useful technique that will reduce the load that your theme images takes up and greatly reduce the number of requests to your server. If you cannot do this step yourself, ask your theme designer to help you with this procedure.

Use Keepalive

Keepalive allows connections from browsers to your server to stay open. This will greatly reduce the overall time that a browser takes to download all files from your server as it does not need to request for files again. In essence, it can download files when it wants.

Keepalive can be enabled through .htaccess, Apache, NGINX or Litespeed. If you are on a basic shared hosting plan, your hosting company may not permit you to enable Keepalive as it can affect performance for everyone on the server. Therefore, you should speak directly to your hosting company about this feature and ask if they can enable it. You can also do this directly yourself by adding the following code to your .htaccess file:

Header set Connection keep-alive

If you would like to know more about Keepalive, I recommend reading the great article from Patrick Sexton on Feedthebot entitled Enable keep alive.

Utilise Browser Caching

Browser caching allows you to reduce the load of your pages by storing common files on the visitor’s browser. This can greatly reduce the speed of your website for people who visit your website frequently. Once it has been enabled, the browser will be instructed to download files locally, rather than downloading them again from your server.

Browser caching can be enabled by adding the following code to your .htaccess file:

## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 2 days”

## EXPIRES CACHING ##

Most browsers have browser caching enabled by default. Therefore, once you have activated this for your website, your return visitors will be able to download your pages quicker.

Place Scripts at the Bottom of Your Pages

It is common for website owners to load scripts (e.g. Javascript) at the top of a web page within the head area of the document. Whilst it is good practice to always load stylesheets at the top of a page, we should all be loading scripts at the bottom of the page i.e. just before the closing body tag. This technique is strongly recommended by Yahoo.

High Performance Web Sites: Rule 6 Move Scripts to the Bottom, states that:

Rule 5 described how stylesheets near the bottom of the page prohibit progressive rendering, and how moving them to the document HEAD eliminates the problem. Scripts (external JavaScript files) pose a similar problem, but the solution is just the opposite: it’s better to move scripts from the top to as low in the page as possible. One reason is to enable progressive rendering, but another is to achieve greater download parallelization.

With stylesheets, progressive rendering is blocked until all stylesheets have been downloaded. That’’s why it’s best to move stylesheets to the document HEAD, so they get downloaded first and rendering isn’t blocked. With scripts, progressive rendering is blocked for all content below the script. Moving scripts as low in the page as possible means there’s more content above the script that is rendered sooner.

Placing scripts at the bottom of your page appears to go against what all of us were taught when we first learned how to build websites (that is, scripts should always be placed within the head area of a page). Yet, the reasoning behind this is sound. By placing scripts at the bottom of your page, you will allows give priority to your design and content loading before scripts are.

Use Managed WordPress Hosting

If all the steps detailed in this article are a little daunting to you, or if you simply do not have the time or energy to optimise your website; you may want to consider hosting your WordPress website using a managed WordPress hosting service. Managed WordPress services ensure that your WordPress website runs as fast as it can. They apply many, if not all, of the techniques discussed in this tutorial. Companies such as Zippy Kid will also configure your website for a content delivery network.

In order to ensure that customers website’s are optimised, some managed WordPress companies restrict what customers can do. For example, Web Synthesis do not allow .htaccess files to be used and do not offer any access to a hosting control panel.

Unfortunately, managed WordPress services charge a premium when compared to other hosting services. For example, WP Engine charges $99 per month for around 100,000 page visits per month. That is around three to four times the monthly cost that most hosting companies would charge for the same level of storage and traffic.

Managed WordPress Hosting

I tried out Web Synthesis briefly for my WordPress websites. Due to my hands-on approach to managing my websites, I found their service very frustrating as I was not able to manage my website myself. I can, however, see why so many people use managed WordPress services. In addition to handling all your optimisation and security requirements, you are getting support from a company that specialises in WordPress.

WordPress is such a popular platform that the support teams of all hosting companies have a good knowledge of it; but you will find that most hosting companies do not offer dedicated WordPress support. That is, there is a limit to what regular hosting companies will provide support for. Therefore, if time is a big concern for you and you would prefer your hosting company to handle all WordPress related problems, a managed hosting service may be perfect for you.

There is an alternative solution available if managed hosting services are out of your budget. Rather than pay for a managed hosting company to host and manage your WordPress website every month, you can host with a regular hosting company. Then simply pay someone such as Matthew Horne from DIY WP Blog to optimise your website for you. This is arguably a better solution in the long run as once a website has been configured correctly, you just need to maintain those settings.

The important thing to remember is that even if you do not feel comfortable optimising your WordPress website itself; there are people out there who can do it for you. Just be aware that this option is always more expensive.

An Overview on Speeding Up a WordPress Website

There was a time when I thought that only hosting companies and WordPress gurus could optimise WordPress websites. Nothing could be further from the truth. Simply optimising your images, compressing your code and caching your content, is sufficient to reduce your page size by a huge margin.

The key to learning what works and what does not work is to test your website speed after any modification. This will show exactly how a newly applied technique or service has improved your website speed. Do not be afraid to ask your hosting company for help. They will be able to advise you on many optimisation procedures, such as configuring your caching plugin correctly or enabling features such as Keepalive.

If you want to focus on updating your website and not concern yourself with technical issues, you may want to consider hosting your websites with a managed WordPress hosting company. They can optimise your websites for you and offer premium WordPress support.

I hope you have found this tutorial on speeding up a WordPress website useful. I also encourage you to bookmark this article for future use. If you need me to clarify any part of this tutorial, please let me know and I will do my best to delve into the issue in more detail.

This article was authored by:

Kevin Muldoon is a professional blogger with a love of travel. He writes regularly about topics such as WordPress, Blogging, Productivity, Internet Marketing and Social Media on his personal blog and and provides technical support at Rise Forums. He can also be found on Twitter: @KevinMuldoon and Google+.

Kevin Muldoon has authored 833 posts.Visit Website

Showing 8 Comments

  • What about commentluv speed?

    REPLY
  • Use W3 Total Cache :)

    REPLY
  • Hi,

    Great tips. Thanks. I use NIX Gravatar cache to cache gravatar pictures in comments. If post have many comments, that reduce http request and load time.

    REPLY
  • Great and elaborate article, very helpful…

    Avoid unnecessary and fancy widgets; for simple displays like popular posts, categories etc. writing 2 or 3 lines of code to fetch these in sidebar.php (theme file)is sufficient.

    REPLY
  • Great post man!

    One of the best and most comprehensive articles I have seen on wordpress performance optimisation. Must have taken you a ton of time to complete.

    Kudos, awesome job!

    REPLY
  • Great and detailed elaboration to speed up the website. I think CDN plays vital role to load the website faster. Thanks for the tips.

    REPLY
  • Great details. Never seen such details in any other sites on increasing the speed. Will follow these for sure for my website.

    REPLY
  • ys-sanitize-output plugin is also usefull to reduce page size

    REPLY

Add Your Voice: