Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

18 Useful Tricks To Speed Up WordPress & Boost Performance

Last updated on by
Follow WPBeginner on YouTube
18 Useful Tricks To Speed Up WordPress & Boost Performance

WordPress is a good CMS solution and even better blogging platform, but most sites using WordPress are not maximizing its potential. Performance is one of the important factor of a successful website. In this article we have compiled a list of useful tips, tricks, hacks, and plugins that can be used to speed up WordPress and boost it’s performance.

These tricks are for different skill levels and some might even seem very obvious to you, but please bare with us as we want to satisfy the needs of users on all skill levels. These tricks are very easy to implement, so you should start now.

1. Cache Complete Generated Pages

WP Super Cache

WordPress is a PHP script, so everything is dynamic, which means every time a page is loaded, WordPress must execute the queries hence making the site load slow and even crash due to the server load if you experience high traffic. The best solution to this problem is by using static pages. A plugin called WP Super Cache cache complete generated pages and serve those to your users instead of processing the heavy dynamic queries. Once you have installed this plugin, you will see significant decrease in your site load time and much more efficiency in the usage of server resources.

2. Disable Hotlinking and Prevent Leeching

Stealing is Bad

Hotlinking is also known as bandwidth theft. It is when other sites direct link to the images on your site from their articles making your server load increasingly high. If one site does it, it might not make a significant difference, but there are too many spammers that will do this and that is something your server cannot hold specially if they copy your article with a lot of images. No matter how good your web host is, it will be slowed down if hotlinking is not prevented. There are a few ways you can disable hotlinking. First way we will share is through your root .htaccess file where you will place this code below:

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wpbeginner.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/wpbeginner [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L] 

You can make an image that will replace all hot linked image that will say Stealing is bad or something so it makes the spammer look stupid.

Remember you must allow your feed otherwise your feed readers would not see any images.

Source: Josiahcole

3. Choose a Good Web Host

Choosing the Right Web Hosting Service

This might seem like a very obvious one, but a lot of the times people try to save a few bucks and compromise quality. It is not worth it. Pay the extra few dollars and get a better web host. One that is reliable and have strong servers. We have a beginners guide at WPBeginner where we help you choose the web host for WordPress.

Some good and affordable web hosts:

4. Split Long Posts in Several Pages

If you are making a mega resource which will require you to list about 100+ resources and you will have 100+ image on the post. It is best that you split the post into multiple pages, so each page loads much faster, and you increase your pageviews. This is very easy and it is doable from the WordPress admin panel if your theme already has this function. When writing the post you just have to enter the following code when you want to split pages:

<!--nextpage-->

You must make sure that your template has the function. Check out the Template tags in the Codex.

5. Use Excerpts and Limit the Count of Posts Displayed on Blog Page

Use Excerpts on Blog Page

You should never show full posts in the main blog page because you have 5 or 10 total posts on the same page. If each of your post is a list post and it is displayed in full text mode, then it will be very inconvenient for your users because the page will take immense amount of time and server resources to load. Therefore you must use excerpts and limit the count on how many posts are displayed.

In order to display excerpt, you must visit your index.php and find:

<?php the_content(__('(more…)')); ?>

Then replace this with:

<?php the_excerpt(__('(more…)')); ?>

Now the second step is to limit the number of posts being displayed on your blog page. You can do that through the WordPress admin panel under the tabs Settings > Reading:

Post Count on Blog Page

6. Optimize Your MySQL Database

Optimizing your MySQL Database can make a difference in your load time. There are two ways of doing this. One way is manual hard core way. Another way is a plugin. To do it manually, you need to go to phpMyAdmin and select your database. Then towards the bottom, click check all to select all tables and then towards the center of the screen, there is a drop down menu, click optimize tables there.

Optimize MySQL Database

If you don’t want to do it manually then Joost De Valk has a plugin for you. It is called Optimize DB, this plugin does exactly what we mentioned above except you don’t have to mess with phpMyAdmin.

7. Reduce the Use of External Websites and Scripts

Try to avoid relying on external scripts whether it is directly or through the plugin. Some plugins like MyBlogLog and others can take a lot of time to load depending on the server connection. They can often be the reason for page not loading properly if you are experiencing high traffic. To display widgets from top directories, alexa and others in your sidebar only slows your site down. Try to avoid it as much as you can.

8. Add Expires Header to Static Resources

An Expires header is a way to specify a time far enough in the future so that the clients (browsers) don’t have to re-fetch any static content (such as css file, javascript, images etc). This way can cut your load time significantly for your regular users.

You need to copy and paste the following code in your root .htaccess file:

ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000

The number 2592000 stands for the number of seconds in a month. You can change that number to anything you desire.

9. Use WP-CSS

WP CSS

WP-CSS is a plugin that uses shorthand technique. It GZIP and strip whitespace from your CSS files. It allows you to confidently use @import inside a CSS file and not worry about what happens on the user’s end. It will look through your style.css file and put any @import files into it. Using shorthand technique can make a difference in your site load time because it makes the file size smaller.

10. Compress JavaScript Files

JavaScript files are loaded in almost every page and sometimes they can be large files. Even if it is a small file, being repeatedly loaded can eat your resources and have an impact on your load time. You can use the compressors to compress the JavaScript and save resources as well as increase the speed of your WordPress site.

11. Reduce Image Sizes

This one is a gimme, but it must be reiterated here. Images help make your blog posts lively, but you do not have to put extremely high resolution images in your blog posts and even in your web design. The bigger your image, the slower your site will load and the more server resources you will use. If an article with images gets popular in social media and you get tons of traffic, you can even get suspended from your web hosts if you exceed the limits. Therefore it is best if you have low image sizes. You can obtain this by using a plugin called WP Smush.it. This plugin reduces the image size with minimum quality loss. You can also use this directly from the site Smush.it.

12. Do a Plugin Check and Remove Inactive Plugins

If you are using more than 15 plugins on your blog then you need to check to see if you really need all of those. If you don’t then you need to delete them. Also remove the inactivate plugins from the site. While checking for plugins, make sure that you use the proper format when including the plugin in your template files. Instead of including the code like this:

<?php refer_thanks(); ?>

You should add it like this:

<?php if (function_exists('refer_thanks')) { refer_thanks(); } ?>

Having it this way ensures that WordPress will only pull that code on the page if this plugin is active. If you use the first way of coding, and you inactivate the plugin, your page will load with error and sometimes it even displays on the page that there is an error.

Source: Yoast

13. Cache Your Database

WordPress is fully integrated with MySQL therefore when a page is loading, multiple database queries are being executed which takes time. A plugin called DB Cache caches the database query and make the site load much faster.

14. Split Comments into Pages

Every site has few articles that went viral. These article generates tons of comments and they can consume enormous amount of server resource upon each visitor loading the page. Or maybe your blog is already popular and you are getting a good discussion going in your posts, then it is recommended that you paginate the comments to increase your site loading speed and save server resources. This can be done by going into Settings > Discussion in your WordPress Admin Panel.

Paginate Comments

15. Reduce the Number of Database Calls

Database calls make WordPress so dynamic, but sometimes you can live without it. By replacing simple text, you will be able to increase your WordPress speed. To give an example look at your header.php code which looks something similar:

<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="
<?php bloginfo('html_type'); ?>;
charset=<?php bloginfo('charset'); ?>" />

This code above is calling useless database queries which you can simply put in as text. Like in the example below:

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

By making it slightly less dynamic, you have saved yourself some load time. If you get a custom theme designed for a specific WordPress site then there is nothing wrong with removing these because it will only be used by you.

You can also reduce database calls by doing the following:

  • make your stylesheet URL’s static
  • make your pingback URL static
  • make your feed URL’s static
  • you can remove the blog’s WordPress version

Source: Yoast

16. Cutting Down the Size of MySQL Database

When writing posts, now WordPress actually autosave which even after the post is saved, the revision articles stay in the MySQL Database. Bigger database also bring the site load time down. If you are not using Revisions then you can remove them by adding the following code to your wp-config.php

define('AUTOSAVE_INTERVAL', 500 ); // seconds
define('WP_POST_REVISIONS', false );

You can also delete unnecessary tables from the Database like:

DELETE FROM wp_posts WHERE post_type = “revision”;

Note: Only do this if you don’t use revisions. If you like to have revision in WordPress then do not take this action.

17. Stay Updated with the Latest WordPress Version

Ofcourse this is a must. You should always stay updated with the latest stable release of WordPress in order to boost performance of your site. If you don’t do this, you are also putting your site in security risks.

18. Display Page Loading Time and Queries

Display Query and Loading Time

In order for you to track how well your site is doing, it is wise to add this code in the footer. If it is a low number then it means your site is at its potential. Just paste this code in order to display page loading time and queries:

<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.

What tricks do you use to speed up WordPress? Share it with us in the comments. We will add it in the post, so everyone else can use it as well.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • http://in2gpu.com/ Sergiu Craitoiu

    Thanks good advices

  • Jennifer Ortiz

    WP-CSS is no longer in the wordpress repository. Any suggestions for an alternative that you like?

  • Alex

    Hi , this is an excellent post. You gathered all the useful information in one article.

    I just uploaded my website and I used W3 Total Cache. I have seen a boost of at least 20% in speed. I have done the testing from the following sites.
    http://tools.pingdom.com/ ( from about 70% now is 89%-91%)
    http://www.webpagetest.org/result/130221_KP_FBS/ ( from about 72/100 now is 87/100)
    http://gtmetrix.com/ (from 72-73 now is 90%)

    The next step that I will do is to use CDN although my website content is small. Maybe I can increase the perofmrance of my site even more.

    thanx…keep up the good work

  • SamediAmba

    Thanks for the comment and suggestions. I was in need of such solutions for my slow website, and I found them here

  • kiruthika

    Hi! I’m impressed, I must say. Really rarely do I encounter a blog that’s both educative and entertaining, and let me tell you, you have hit the nail on the head. Your idea is outstanding; the issue is something that not enough people are speaking intelligently about. I am very happy that I stumbled across this in my search for something relating to this.

  • babon3000bc

    Thanks for your useful post. Please keep it up & give us more powerful tricks & tips :)

  • theconservativeblog

    quick msg to say thanks so much for tutorial, reduced my site loading time from 11 seconds all the way down to 2 :)

  • http://phill.co Phill Ohren

    Great tips. This should be number one in Google not 2nd! Thanks heaps.

  • http://ferodynamics.com PJ Brunet

    You can chase your tail looking for a little optimization here, a little there. Don’t get caught in that trap like I did. This is like trying to hold your spoon different ways to dig a tunnel faster–when a shovel (VPS) costs the same as a (shared server) spoon.

    None of these changes matter if you’re on shared hosting with 100s or 1000s of other websites. If you get a solid VPS (same cost as shared hosting) you won’t need most of these tweaks. The color of your shoes won’t help you win a marathon.

    Most speed problems out there are due to overselling servers and weekend warrior plugin authors who don’t know what they’re doing. When it comes to hosting, it’s not true you get what you pay for, that’s a myth. Low cost = more business, cheaper bandwidth. Research the hosting business if you want fast hosting–run tests, look at benchmarks, find where the fastest blogs go for hosting. This is important even for small bloggers. You can’t grow traffic on a slow server, you hit a glass ceiling the first day on the job.

  • http://www.mundoestetica.com.br Edson Bassani

    Thank you so much! Your post had save me a lot of headache and my blog is running really faster right now. Thank you again!!!!

  • http://pbjbreaktime.com Icechen1

    Nice! Thanks so much for this list, I’ve been looking for ways to speed up my blog for quite some time now and this is just what I needed!

  • http://mindofwill.com will

    Thanks i have used almost all of these but i use w3 total cache and my site runs much better now.

  • http://netvarp.sigurfreyr.com Sigurfreyr

    Really helpful. I was looking for this kind of information. Used Google, but couldn´t find any useful concrete tips really. Opened my Twitter just to do something else. Then I ran in to one of your tweets (I don´t even remember ever following you :-). Anyway Twitter brought me to your website which I am now reading for the first time. It is packed with all kinds of info I have been looking for. Just shows me this social media stuff really works. Also nice to see you recommend Bluehost. I signed up for their service out of the blue (so to speak) back in 2001. Did not do any research on what would be a good host. Pure coincidence I choose them. But have been really happy with their service. Their Fantastico and now Simple Scripts (installing all kind of databases, CMS, webshops etc.) with 1 click of the mouse is really helpful feature they provide.

  • http://www.flamescorpion.com FlameScorpion

    Hotlinking images is a bad habbit, if the site where you hotlink is removed, then you will end up with a big notfound on your page.

    I use tools to test the speed of my website. The best i found is http://loadimpact.com/

    • Shemul

      What’s about GT Metrix, Pingdom and Google page speed. I use them

      • http://www.wpbeginner.com/ WPBeginner Support

        These are all good tools.

  • http://junkiee.net Nina

    Great stuff, totally useful.
    Thanks for posting :)

  • http://www.jockpost.com JP

    Just did #6 on your list. And removing all the PHP queries from the header/footer is an easy and fast way to speed up your site pronto!

  • http://www.amberweinberg.com Amber Weinberg

    I don’t recommends the Super Cache plugin. It actually slowed me site down and I had to clear it everytime I made an update.

    I do recommend trying wp minify – it compresses all your css and js files.

    • http://www.scwebdesign.com.au Liam

      If you tick do not cache pages for logged in users you won’t have that issue of having to clear the cache everytime. I usually leave caching as the very last thing I do.

      Terrific thread.

    • http://www.wpbeginner.com Editorial Staff

      We are using it on this site. Have used it on all the client’s website and never had any issues.

    • http://www.fenderstrat.net Strat

      I’ve never heard of WP-Minify before, but it looks pretty good. I’m going to try it on a few of my sites, thanks

  • jack

    is it recommended to store repeating functions results in variables?

    For example, if I have the_title() or the_permalink() functions appearing more than once in my index.php.
    Will it be faster if I type and then echo $title1?

    • http://www.wpbeginner.com Editorial Staff

      No it will not be faster, because it is different for each post. So it will still have the same amount of queries.

      • jack

        thanks, but I meant for the same post.
        the_permalink() function is called for the post title link in the first time, and then it is called again (for the same post) for the link to the post comments (this link is the number of comments next to the post title)

        • http://www.wpbeginner.com Editorial Staff

          Don’t think it would make that much of a difference.

  • http://www.techvorm.com Paritosh

    WP CSS plugin is compatible upto version 2.6.2. Any other similar plugin you suggest ?

    • http://www.wpbeginner.com Editorial Staff

      Sometimes plugins author don’t update the plugin compatability but it still works. Have you tried it with the latest version?

  • http://easypublicspeaking.co.uk/ Keith Davis

    After all the hype about WordPress, I find that my one wordpress site is much slower than my html sites!

    I’m goint to have to speed things up a bit.
    WP Super Cache looks like the plugin that everyone uses so I may start with that.
    Thanks for a comprehensive list of how to get things moving.

  • http://www.juegos.gs Arturo.S

    Thanks for the article, I think W3 Total Cache and Php Speedy are also good alternatives.

  • http://inspiredbywordpress.co.uk Daniel Groves

    Nice collection. Will be coming back to this in the future.

  • http://somebodysomeone.org Jef

    Great list!

  • http://www.your-health-news.net health blog

    Thanks for the advice. I’ll follow that up as my own blog is too slow..

  • http://code.google.com/p/web-optimizator/ sunnybear

    To tune client side perfromance of your blog you can use Web Optimizer plugin, http://wordpress.org/extend/plugins/web-optimizer/ . It increase your website load speed usually by 200-500% by applying all best practices from YSlow.

  • http://www.dmrossi.com dR

    Thank you very much for the info. This post was extremely helpful.

  • Tutivillus

    WP Super Cache can cause some serious problems. Check with your Host.

    A good alternative is Hypercache.

    Also research caching your Database BEFORE doing it. A good option, yes, after you know it will work for you.

    [Author link removed, Please don't add adult sites there]

  • http://www.IgorHelpsYouSucceed.com Igor

    Extremely useful post, thank you!

    Igor

  • http://www.facebook.com/jasonberkes Jason Berkes

    Just found your site and I love it. Great information.

    Thanks

    Jason Berkes

  • http://www.myhtmlworld.com Sunil

    Thanks for sharing :)

  • http://www.icyslounge.de Marko (dericy)

    very usefull tipps :)

  • http://www.oleksabublik.kiev.ua oleksabublik

    My advice – don’t get http://www.midphase.com. Their overload policy is weird and custom support guys seem to have just left the nursery. Stayed for two years with them – awful!

  • http://jaledwith.com/ Andrew

    On #18, what would be considered good loading time? The example you have in the pic is under 1 second. I’ve add the code to my site and I am consistently loading pages between 1 and 3 seconds. Is that too slow?

    • http://www.wpbeginner.com Editorial Staff

      #18 is just for you to see how long it takes and how many queries your site is running.

      • Tim

        Great list – thanks.

        AS to what should be considered good? Speed is going to vary from server to server. Be a limbo dancer and just get as low as you can. I have a big WP site (16,000 posts and loads of custom fields) to optimise – my target will be to get script execution under 1 sec (don’t laugh at me :-) ). But that is a target, and I will be pleased to get even remotely close.

  • http://thebirdsinthemeadow.com/ Bird

    Wow, this post really is a great resource – as a non-tecchie I am always on the lookout for stuff to make my blog more efficient and there are a lot of things here that I didn’t know about and want to try. I’d certainly recommend the WP super cache plugin to anyone who hasn’t got it – it speeded my site up no end. Thank you for these genuinely useful tips!

  • http://blog.fazai38.com Fazai38

    Here’s a good article for me… as my blog had memory problem.

    Thanks for the tips.

  • http://www.nextlevelblogger.com Christian

    Thanks for this awesome list. Great mini-tutorials with each step also. I totally agree on running only as many plugins as absolutely necessary.

  • http://www.fasblog.com/ fas

    Those are some awesome tips. What about coding more and pluging in less?

  • http://wpantivirus.com Sergej Müller

    Thanks for tips. See also this css & javascript compressor: http://compressor.ebiene.de

  • http://selfconclusion.co.uk Stu | Selfconclusion.co.uk

    Great post thanks! alot of cool tips in here!

  • http://techblissonline.com/ Rajesh

    Another tip:

    Use Chennai Central plugin and save bandwidth – http://indiafascinates.com/chennai/chennaicentral/