How to speed up Wordpress.

To speed up wordpress is often an easy task, although it takes a little reading and learning. Of all the available CMS platforms WordPress is by far the most used platform of all. About 20% of all websites on the internet use WordPress and of all the websites which use a CMS, 60% uses WordPress. This is also one of the reasons there are many good optimization plugins and “tricks” available. The problem with WordPress is that it can get really slow when you leave it in its original install form without tweaking it. All in all good reasons to list the best ways to speed this CMS up on your own.

Remove unnecessary Javascripts from header and footer

WordPress loads a couple of Javascripts, like the jquery.js script, which most WordPress sites do not need to use if they simply want to display their pages. Also, sometimes badly coded custom theme installs come with various Javascript codes which aren’t used or necessary as well. These codes, most often found in the header and the footer, slow your website down because the scripts take time to load and also add extra HTTP requests.
Make your way to the WordPress Editor (Appearance>>Editor) and click on the header.php page in the right sidebar. Make a backup of your code and experiment with removing all (yes, all) of the javascript codes to see if it affects your website in a way you do not like. If it does affect the website, replace it with the old code you made a backup of. Experiment with removing every script one by one and only remove the scripts which do not affect your website. Now open the footer.php code in the editor and do the same. Remove as many scripts as you can. The lesser the better.
Again, remember to always save a backup of your code before you remove anything so you can add the old codes back in if removing a Javascript does affect your website.

Use a cache plugin

Every time a visitor loads a page on your site, WordPress looks for the freshest version of that page. This means it has to continuously load the database to retrieve this fresh information. In most cases this loading of the database is totally unnecessary because most pages do not change often after they’ve been created. A cache plugin fixes this problem by making a static copy of your pages and delivering it to your visitors, without loading the database with every visit, also known as caching. This speeds up the loading times of your pages significantly.
One of the best plugins is WP Super Cache. Many people also use W3 Total Cache which is a great plugin as well. There are various other cache plugins which you can use as well.

Use WP Optimize

WP Optimize is a great little plugin which helps you clean and minimize your WordPress database. You can optimize your MySQL database, empty the trash, remove post revisions, delete spam comments, remove pingbacks and trackbacks with one simple click of the mouse. With some websites it has reduced the database size by 80% or more. This can greatly improve speed, especially when your database loads often. Use this plugin with caution, do not clean/delete things you aren’t sure of.

Enable caching in the .Htaccess file

If your webhost has enabled mod_expires on your server you can use a .htaccess file to enable and change how often your website caches HTML files, CSS files, Javascripts, images, PDF files and other types of files. This means these files only have to be loaded once. After this initial visit the files are saved on the computer of your visitor. Now every time the visitor visits another one of your pages it will be loaded from his computer, which speeds up the process. You can set the amount of time this cached files will be renewed with a fresher version in the .htaccess files. It can be set in seconds, minutes, hours, days, weeks, months and years. Below is an example of a code you could use, change it to your needs, place it inside your .htaccess file (found in the root folder of your website) and upload it:

<IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access 14 days" ExpiresByType text/css "access 7 days" ExpiresByType text/html "access 2 days" ExpiresByType image/png "access 1 month" ExpiresByType image/gif "access 1 month" ExpiresByType image/jpg "access 1 month" ExpiresByType image/jpeg "access 1 month" ExpiresByType text/x-javascript "access 1 year" ExpiresByType application/pdf "access 1 week" ExpiresByType image/x-icon "access 2 months" ExpiresByType application/x-shockwave-flash "access 7 months" </IfModule>

More information about caching to make your website faster can be found here.

Enable WordPress Gzip compression

Enabling Gzip compression will compress your pages to a much smaller Gzip file format, sometimes as much as 75%. This compressed version of your pages are sent to the visitors browser (all browsers support it) which will decompress it and display the page correctly. This will speed up your website because the Gzip file is smaller as the original page. To enable Gzip compression in WordPress you simply visit in your browser, find the gzipcompression setting and change it from 0 to 1. Use the Gzip Compression Test to check if it works.

Minimize the use of social media buttons

Every social media button (Facebook, Twitter, etc.) requires the browser to load all the necessary files from the website of the particular social media site. This can add a lot of extra load time and HTTP requests. If you insist on using the buttons you should always host them on your own site.

Minimize plugins & disable slow ones

Some plugins can greatly decrease the loading speed of your WordPress pages. Uninstall plugins you do not need. Always test a plugin before you use it. If it slows down your website, try to find a different way of fixing the issue the plugin helped you with. Use P3 Plugin Performance Profiler to detect which plugins are slowing your website down.

Optimize your images

By minimizing the disk size of your photos and images you can speed up the loading times of your pages. There are various tools to do this. Top optimize PNG images or JPG images for the web you can use the PNG Compressor or the JPEG Compressor, sometimes it can reduce the size by 50% or more. One of the most popular plugins for WordPress is EWWW Image Optimizer plugin. This plugin uses most of the available image compression techniques(optipng, jpegtran, pngquant, pngout, and gifsicle) with a simple click of the mouse. There are also other good plugins available like WP

Use CSS image sprites

Most websites use a variation of images in the design of the theme or for certain functions. Every time these images load it adds extra HTTP requests. One way to minimize the amount of HTTP requests is to use CSS sprites. CSS sprites give you the ability to combine several images into one, while still using them individually in different places on your page by using X and Y coordinates defined in a CSS script. This way you only have to make 1 HTTP request to load multiple images. Use the CSS Sprites Generator to create sprites, as well as instructions to place them on your site.

Lazy load photos

You should lazy load your photos for a faster visitor experience by improving your initial view content loading.

Inline CSS & Javascripts

Inline your CSS scripts and Javascripts to speed up the rendering of your pages.

Can’t inline? Combine all CSS Or Javascript files in one big file

For help with Javascripst go here. About CSS files; most WordPress themes load multiple CSS files, sometimes as many as 10 or more in the header. This adds unnecessary HTTP requests which can affect website performance. Copy the code of all the CSS files and add it to one CSS file. Now go to the WordPress Editor, open the header.php code and replace all the CSS lines with one CSS code which points to the big CSS file. Or, even better, copy the code from the big css file and instead place it inside the header in style tags like this:

<style> the CSS code </style>

This will load your page even faster.
You can also use the CSS Compressor to minimize the size of your code significantly. Make a backup of your code before you use this tool though, it will mess with and change the structure of your code to make it the smallest possible.

Use a HTML Minifier plugin

Use a plugin which can automatically minify your HTML code for you. A great one is WP HTML Compression. It works great on most websites and has very few bugs. Try it on your own sites if it works for you.

Use asynchronous scripts

Using asynchronous scripts will increase the load speed of your website because the loading of the ads does not interfere with the loading of the page. In short this means that even if these scripts load slowly your page can finish loading and be seen by your visitors without loading the script first. See here for more information.