elegant themes

38 ways to optimize and speed up your WordPress blog

| April 23, 2008 | 74 Comments

WordPress blogs and sites can be notoriously slow. But fear not – here are ways to make your WordPress blog super speedy and fun for your visitors to view with a few tweaks, hacks and plugins. Be sure to check back because I will be updating this post as I discover new and wonderful ways to optimize and speed up WordPress blogs.

Matzah[This post is in honor of the current Pessach (Passover) season, a Jewish holiday where we clean our houses frantically in the hope that not one crumb of leavened bread (i.e. regular bread) be found during the 7 day holiday. This post is the WordPress version of Pessach cleaning, where cluttered databases are equivalent to leavened bread, etc. Happy Pessach!]

Define goals and create benchmarks:

  1. First, define a goal, such as reducing page load time from 8 seconds to 2 seconds.
  2. Measure your initial state and the results of each modification so that you can quantify any improvement. Test your site’s speed with the Website Speed Test, but do multiple tests since the results can be inaccurate due to fluctuations in your internet connection and other factors.
  3. Use Pingdom to get a detailed analysis of your blog’s loading time and performance.
  4. See what your browser is doing with tools like Firebug’s network tool, Charles Proxy or Wireshark, and review the server logs.
  5. YSlow – analyzes web pages and tells you why they’re slow based on the rules for high performance web sites. YSlow is a Firefox add-on integrated with Firebug. See this presentation from Yahoo! that covers their latest research results and performance breakthroughs. It covers their existing 14 rules, plus 20 new rules for faster web pages. They’ve categorized the optimizations into: server, content, cookie, JavaScript, CSS, images, and mobile.

     

    SlideShare | View | Upload your own

Reduce the number of dynamic PHP and http calls:

  1. “There is an inherent overhead in each HTTP request. It takes substantially less time to serve one 30K file than it does three 10K files.” So combine all files in a type into a library. Learn how here.
  2. Use different host names to increase the number of active download threads.
  3. Minimize PHP and database queries – Each time a page on your site loads, if your browser has to execute any PHP queries, it adds to the load time. If you replace the PHP queries with static HTML, every time a page loads, your browser just reads the HTML. An example from WP Candy:
    With PHP requests: <title><?php bloginfo(’name’); ?><?php bloginfo(’description’); ?></title>
    Without PHP requests: <title>WPCandy - The Best of WordPress</title>
    Joost de Valk says that you can remove 11 queries to the database by doing the following in your header.php and footer.php files:

    • making your stylesheet URL’s static
    • making your pingback URL static
    • making your feed URLs static
    • removing the blog’s WordPress version
    • making your blog’s name and tagline / description staticSee more examples of how you can replace code in your WordPress template files with static HTML here and here.
  4. Check if you have too many external calls to things like Amazon, eBay, MyBlogLog, etc. Try commenting them out one by one to see if it speeds things up.

Optimize your files: CSS, HTML, Javascript, images, video

  1. Optimize your image files for the web.
  2. Make sure that all images have height and width tags.
  3. Consider hosting your images on an external site like flickr that has huge servers and can handle the load.
  4. Use CSS sprites for static web images. CSS sprites are where the images are added to one larger image file, and laid out in a convenient way. Here’s a CSS Sprites generator.
  5. Do not host videos on your server. Upload them to YouTube, Google Video, or any other video sharing site and let them handle the server load.
  6. Compress your Javascript, using a tool or by removing formatting (and potentially by shortening function and variable names). This can reduce file size by 60%. Add gzip compression to that as well and you’re looking at a serious size reduction.
  7. Compress HTML and CSS by removing HTML formatting, white space (where you divide code among separate lines for easier readability), trimming class names, omitting unambiguous quotes around attributes, etc.
  8. Compress your CSS with the CSS Compress WordPress plugin – Automatically removes comments, new lines, tabs, and gzip compresses (GZIP) any CSS file called with “<?php bloginfo(‘stylesheet_url’); ?>” Just activating the plugin with the default Kubrick theme will reduce the CSS file from 8k to 1.7k.
  9. Compress your CSS by using shorthand CSS. Here’s an example from WP Candy:
    Long: .test {margin-top: 7px; margin-right: 1px; margin-bottom: 5px; margin-left: 3px;}
    Short: .test {margin: 7px 1px 5px 3px;}
  10. Use external scripts – Instead of placing tons of code in your header.php file, use external scripts. This allows the browser to cache the script so it won’t have to read it for every other page.
  11. Validate your code at W3C to make sure you don’t have any major errors slowing down your page.
  12. Allow progressive rendering: Load CSS files at the top of the page, from within the head section; load JavaScript files at the bottom of the HTML. And/Or…
  13. Stop slow loading scripts from breaking your blog with IFrameWidgets v1.0 WordPress plugin. Slow widgets or snippets of Javascript can either time-out, or prevent the items below them from loading. The plugin creates WordPress sidebar widgets that run in an IFrame. Since IFrames load in parallel to the rest of the page, slow loading JavaScript widgets won’t affect the rest of the page.

Plugins

  1. Disable or delete unused plugins – some plugins have tons of script and code, and even create database tables in your WordPress database. Use only the plugins you really need, and delete the rest.
  2. Sometimes plugins require that you add a snippet of code to your theme’s template files to call the plugin. Usually, it looks something like this:
    < ?php refer_plugin(); ?>
    However, if for some reason you disable that plugin, you will get an error. Joost de Valk recommends using PHP’s special function called function_exists to prevent the blog from breaking if plugins are disabled or removed. Using it will make the code look like this:
    < ?php if (function_exists(‘refer_thanks’)) { refer_thanks(); } ?>
  3. Control when your WordPress plugins are loaded: WordPress processes all of the code for all active plugins, even if that plugin isn’t used on a particular page. If a particular resource heavy plugin isn’t used on certain pages, then you can tell WordPress not to load it on those pages by wrapping an if statement around the content of each function to check what page is being loaded. Learn more about how to do this here and here.

Database

  1. Use phpMyAdmin to optimize your database: Log in to phpMyAdmin, select all the tables, and then “repair” and “optimize.”
  2. Delete excess records in your WordPress database. All plugins use the wp_options table to store data, which is the same table used by WordPress to store all settings for your blog, and is accessed every time you open any page. When you deactivate a plugin, these records are left behind, bloating your database. To clean it up you can use the WordPress Clean Options Plugin, which finds orphaned options left after you have removed plugins and removes them from the wp_options table, or manually as follows: Back up your database, login to phpMyAdmin, open your blog’s database, and click on browser for the wp_options table. Go through this table record by record to identify any records left behind by old plugins. (from WordPress Web 2.0 Spot-Er).
  3. Use the Optimize DB plugin to optimize the tables of your database.
  4. Use WordPress Plugin: Fix Database to check all tables in your database and fix any errors.
  5. Lester “GaMerZ” Chan’s WP-DBManager 2.11 plugin sorts your database backup files by date in descending order, can repair databases, and allows automatic scheduling of database backups and optimization.

Caching and protecting for server overload

  1. WordPress has a built-in caching system. Learn how to enable the default WordPress object cache. This has apparently been disabled in version 2.5.
  2. WP-Cache 2 – caches Worpress pages and stores them in a static file for serving future requests directly from the file rather than loading and compiling the whole PHP code and then building the page from the database.
  3. WP Super Cache – This plugin is a fork of the WP-Cache 2 plugin, and generates html files which are served without ever invoking a single line of PHP.
  4. PHP Speedy – PHP Speedy is a script that you can install on your web server to automatically speed up the download time of your web pages.
  5. Use the Expires and cache-control max age headers for all pages; Make dynamic pages support the if-modified-since request header; Use far future expiry headers on static resources; Use the cacheability engine to test that you have caching and validation set up correctly. If you don’t know what all this means, don’t worry, neither do I, but you can find out more here.
  6. Digg Protector plugin – The Digg Protector will determine if a visitor is from Digg, and if the visitor is indeed from Digg, the plugin will serve them a remotely-hosted version of the image. Otherwise, the plugin will serve the locally-hosted (on that server) image.
  7. Some more caching possibilities: MySQL query cache, PHP Compiler Cache. Learn more here.
  8. Configure Apache for maximum performance.

Happy Optimization!

Sources:

Speed up your website: Part One

How-to: Optimize your site for speed – really excellent article with practical tips

How to Enable the Default WordPress Object Cache – talks about wp-cache, wp-cache 2, and built in wordpress caching.

Digg Protector

4 Simple Ways To Speed Up WordPress

Speed up and clean up your WordPress!

5 Tips to Help Your Slow or Sluggish Blog or Web Site (WordPress Especially)

Deleting excess records in your WordPress database

WordPress on Speed: 17 Tweaks to Accelerate your WP

The 3 Easiest Ways to Speed Up WordPress

WordPress Theme Hacks

Diggproof & Speed up Your WordPress Blog

WordPress Optimisation: Control When Plugins Are Loaded

Tags: , , ,

Category: Tips

About Miriam Schwab: Miriam is the friendly CEO of illuminea, a WordPress design and development agency. Miriam is a huge fan of WordPress and has been using it for over five years now. In addition, Miriam and her team have been organizing the local Israeli WordCamp conferences for the past few years. View author profile.


Comments (74)

Trackback URL | Comments RSS Feed

  1. Ryan says:

    WP Cache and WP-Super Cache are very good.

    I’m using them at the moment and they do make a noticeable difference. In particular they seriously reduce server load.

  2. DanGarion says:

    Just an FYI the built in WordPress Object Cache option was disabled in 2.5. There is a way to enable it but it’s not really suggested by them to do that.

  3. Miriam Schwab says:

    @DanGarion – thanks for pointing that out, I wasn’t aware that the WordPress Object Cache was disabled in 2.5. I’ll make a correction in the post.

  4. Blake Imeson says:

    Terrific post! This is just what I have been needing.

    Not sure, but I suspect some of my sites are loading slower than they should. After reading this post I had 12+ tabs open of things to do/read. *sigh* Thanks!

  5. Miriam Schwab says:

    @Blake – I know. I’m in the same situation. Sorry to create so much work for you.

  6. [...] Da WordPressGarage.com, un grande post che parla di 38 modi per ottimizzare e velocizzare WordPress. [...]

  7. Susie Q says:

    Hey, great tips- I’ll definitely install wp-cache sometime soon.

  8. [...] By WordPressGarage.com, a great post that lists 38 ways to improve and speed up WordPress. [...]

  9. James Mann says:

    This is an extremely useful post. My MMO wordpress blog loads pretty fast but I have other blog themes that don’t and I didn’t understand why. I am sure this post has everything I need to get them sped up a bit.
     
     

  10. Great article.  Quick question though, if I’m using wp super cache, do I need to do all those changes with the PHP calls as well?  Aren’t the pages cached with the super cache and therefore the php isn’t being called?
    In other words will it dramatically speed things up even thought the pages are cached?

    Thanks!
    Marina

  11. Curtis says:

    Great article, covers just about everything. And I’m glad my post gave you some info, and part two of that post is much more in depth.
     
    Marina,  WP Super Cache takes your files and creates a static HTML file so you wouldn’t need to remove the php.  And yes wp super cache dramatically speeds things up :)
     
     

  12. Ryan says:

    Marina – The caching plugins generate the HTML based on the PHP every time something changes on your site, so you can’t remove them. Without the PHP, there would be nothing to create the HTML! When caching is used, the HTML is stored, whereas when it is not on, the PHP generates the HTML every time the page loads.
    Also, (I think) they dynamically generate the page for anyone who is logged in or who has recently commented on your site.

  13. [...] 38 ways to optimize and speed up your WordPress blog [...]

  14. [...] Für den Planet iQ gab es vorhin ein kleines Update in Form eines neuen Plugins. Mit dem WordPress-Plugin WP-Cache 2.0 wird nun ein Caching der Seite realisiert, sodass sich die Ladezeit relativ deutlich verbessern sollte und Fehler in den RSS-Feeds (vor allem meinem eigenen Feed) nicht zu einer hässlichen Fehlermeldung samt roter Schrift auf fast der gesamten Seite nicht mehr so häufig vorkommen sollten. Der Preis ist die nur noch halbstündliche Aktualisierung der Seite. Nach dem bisher zu sehenden Veröffentlichungsrhythmus der verschiedenen Blogs scheint dies aber nicht schwer zu wiegen. So wird bei den meisten Blogs noch nicht einmal täglich ein neuer Beitrag erstellt. Ein also durchaus praktikabler Kompromiss wie ich finde. Weitere Tipps um die Performance einer WordPress-Seite zu erhöhen, gibt es übrigens in diesem englischen Beitrag. [...]

  15. [...] 38 ways to optimize and speed up your WordPress blog Prova questo: Vedere video su YouTube in High Quality.Tags: WordPress scritto da daniele il [...]

  16. [...] WordPress günlü?ünüzü optimize etmenin yollar?. Ba?lant? [...]

  17. Mosey says:

    Thank you for an extremely helpful article! I’m only beginning to touch the iceberg by following the suggestions from step 1! However, I do have an issue at the moment with a 2.3.3 site that I run, because WP-Cache2 doesn’t seem to work on it (anymore?)  so I’m now forced to turn on the default WP caching, as I’m not sure what effect SuperCache will have on the installation.

  18. Mosey says:

    p/s: Sorry, I just wanted to add that GamerZ “Database Manager” plugin can be setup to automatically repair, optimise and backup databases periodically (e.g. daily) :)

  19. Jacob Santos says:

    The WordPress Object Cache removed the file based portions of the code. Before you could enable and disable whether it wrote/read from a file instead of using the database. That part has been removed. The WordPress Object Cache is always on in 2.5, unless you replace it with another caching plugin.

  20. [...] full article –> 38 ways to optimize and speed up your WordPress blog Tags: optimization, WordPress Posted under: WordPress  Subscribe to this [...]

  21. [...] (yet useful) plugins/themes, it can put lot of load on the server when it comes to memory usage. Miriam has written an excellent post which gives you lot of ways through which you can optimize your WordPress blog and that will also [...]

  22. Ash says:

    Thank you Miriam for taking the time to write such a wonderful guide for optimizing WordPress.  I’ve recently installed the WP-Supercache plugin and its made a big difference in my performance.  I had previously intalled a plugin called WP-Wall (similar to a Facebook type wall) and it caused my hosting company to shut down my site due to CPU overload.  They suggested I install WP-Supercache and since my blog has been running much smoother.  I will also follow your advice about deleting the plugins I am no longer using.  This is something I hadn’t thought of.

  23. Ryan says:

    Ash – You probably already realised this, but I just want to clarify something in case you have misunderstood.

    You don’t need to delete plugins you aren’t using, you just need to delete plugins which are activated that you aren’t using. They don’t do any harm just sitting there, it’s only when you activate them that they become a problem as they start doing database calls, displaying random code in your pages etc.

  24. [...] 38 Ways To Optimize And Speed Up Your WordPress Blog , April, 2008 [...]

  25. JP says:

    In the “Plugins” section above, you have a link to the following:

    wp-admin/Control%20when%20your%20WordPress%20plugins%20are%20loaded

    However this link does not work.

  26. Tim says:

    hmm.. what is the best ways?? I mean i tried using WP-Cache it seems the same and not faster, and i changed to WP-super cache, i cant change the htaccess files as my server is shared among a few sites.. if i change, it cannot be opened so that means rewriting htaccess files cant be done, so basically what is the best way?

  27. Ryan says:

    Tim – if you can’t modify the htaccess file then I think there is nothing you can do. You should get a better host anyway, as you can’t use proper permalinks without changing your htaccess file.

  28. [...] Für den Planet iQ gab es vorhin ein kleines Update in Form eines neuen Plugins. Mit dem WordPress-Plugin WP-Cache 2.0 wird nun ein Caching der Seite realisiert, sodass sich die Ladezeit relativ deutlich verbessern sollte und Fehler in den RSS-Feeds (vor allem meinem eigenen Feed) nicht zu einer hässlichen Fehlermeldung samt roter Schrift auf fast der gesamten Seite nicht mehr so häufig vorkommen sollten. Der Preis ist die nur noch halbstündliche Aktualisierung der Seite. Nach dem bisher zu sehenden Veröffentlichungsrhythmus der verschiedenen Blogs scheint dies aber nicht schwer zu wiegen. So wird bei den meisten Blogs noch nicht einmal täglich ein neuer Beitrag erstellt. Ein also durchaus praktikabler Kompromiss wie ich finde. Weitere Tipps um die Performance einer WordPress-Seite zu erhöhen, gibt es übrigens in diesem englischen Beitrag. [...]

  29. Excellent post, this is what I’ve been looking for. It helped me a lot to improve performance of my wordpress blogs.

  30. [...] answer this question – “Do you think a unique blog design helps in success of a blog?” How about optimizing and speeding up your wordpress installation? Tags: hosting, poll, result, [...]

  31. [...] Für den Planet iQ gab es vorhin ein kleines Update in Form eines neuen Plugins. Mit dem WordPress-Plugin WP-Cache 2.0 wird nun ein Caching der Seite realisiert, sodass sich die Ladezeit relativ deutlich verbessern sollte und Fehler in den RSS-Feeds (vor allem meinem eigenen Feed) nicht zu einer hässlichen Fehlermeldung samt roter Schrift auf fast der gesamten Seite nicht mehr so häufig vorkommen sollten. Der Preis ist die nur noch halbstündliche Aktualisierung der Seite. Nach dem bisher zu sehenden Veröffentlichungsrhythmus der verschiedenen Blogs scheint dies aber nicht schwer zu wiegen. So wird bei den meisten Blogs noch nicht einmal täglich ein neuer Beitrag erstellt. Ein also durchaus praktikabler Kompromiss wie ich finde. Weitere Tipps um die Performance einer WordPress-Seite zu erhöhen, gibt es übrigens in diesem englischen Beitrag. [...]

  32. [...] to WordPressGarage.com for sourcing the [...]

  33. [...] Further Reading: 38 Ways to Optimize and Speed Up your WordPress Blog [...]

  34. Cody Taylor says:

    Great article. I’ve just started trying to reduce server load and decrease page load times because my webhost is trying to force me onto a dedicated server plan. I wrote an article about my experience here : http://codytaylor.org/2009/09/optimize-wordpress.html
    Some feedback would be great

  35. sunnybear says:

    There is Web Optimizer plugin – http://wordpress.org/extend/plugins/web-optimizer/ – that applies all YSlow best practices for your weblog in one click. Just download and acivate.

  36. [...] website of mine. This is why I decided to write this blog post. No matter how much fun it is to update and tune up your website to look like perfection, the thing that really matters is content when it comes to getting organic [...]

  37. Uldis says:

    Realy good post. I try some of tips  – get better speed and more visitors.

  38. GM Baker says:

    Just implemented WP Cache, delted old plug ins and cleaned up my php database. Thanks for the tips! I notice a 3-4 sec increase in load speed. Cheers!

  39. [...] 38 ways to optimize and speed up your WordPress blog | WP Garage WordPress blogs and sites can be notoriously slow. But fear not – here are ways to make your WordPress blog super speedy and fun for your visitors to view with a few tweaks, hacks and plugins. Be sure to check back because I will be updating this post as I discover new and wonderful ways to optimize and speed up WordPress blogs. [...]

  40. [...] 38 ways to optimize and speed up your WordPress blog | WP Garage – [...]

  41. [...] 38 ways to optimize and speed up your WordPress blog | WP Garage – [...]

  42. interconnect says:

    hi thanks for your great article.  i tested my site with pingdom and am confused by the results.  more than half of the load time is in the very first item and i’m not sure what that means.
    here is the archived test:  http://tools.pingdom.com/fpt/default.asp?url=http://todd.benivegna.com/&id=1760535
    this seems to coincide with the fact that i noticed that there is a 2-3 second delay (sometimes 4-5) before anything loads, but once it loads, it loads fairly quick.

  43. [...] posts on this topic:4 Simple Ways To Speed Up WordPress4+1 Ways To Speed Up WordPress With Caching38 ways to optimize and speed up your WordPress blogThe 3 Easiest Ways to Speed Up WordPress18 Useful Tricks To Speed Up WordPress & Boost [...]

  44. [...] quick tutorial is based upon the full 38 Way To Speed Up Your WP Blog article on WPGarage. I have picked out some of the tips for you to use here. The tips I have here [...]

  45. [...] läste jag härom dagen en guide till hur man snabbar upp sitt WordPress. Och ögonen föll på punkten om att gamla plugins kan lämna en massa skräp kvar i databasen som [...]

  46. [...] 38 ways to optimize and speed up your WordPress blog (via WPGarage) [...]

  47. Very interesting article. Im currently using W3 Total Catch, i know have other ideas and thoughts on how to speed up my site.

  48. [...] 38 ways to optimize and speed up your WordPress blog [...]

  49. Amal Roy says:

    Thank you a lot for the wonderful tricks. In my opinion using a cdn network speed up wordpress to a greater extend.

  50. If your wordpress blog have images then you can also reduce them so that loading time cam be reduced. Also the above mentioned methods  are great options provided you use them properly and according to your need.

  51. [...] These 4 points listed above have made a huge difference in my experience, however they are just the start.  If you’ve done the 4 things above and still want more speed, then I’d suggest looking at this article. [...]

  52. ehem ehem :)
     
    What will you get by giving other such cool tips? thanks for the effort :)

    • Miriam Schwab says:

      Aaqil, what we get for giving others cool tips are all the nice thank-you comments from those we’ve helped! And hopefully some people who might hire us.

  53. Jim says:

    Good list.  I wonder how many people realize how significant getting rid of the php in the header is; arguably as much of a difference as caching.
    You missed a cache.  It’s Quick cache and a one button push cache that speeds up my site as much as W3 Total Cache without going through all the convoluted steps.  I use it in conjunction with WP-Minify, which is also an activate and go.  Unlike other caches, these two are simple and don’t require the user to fool with all the files.

  54. Bruce says:

    Miriam,

    Great information here! Thanks for the various ways to speed up WP Blogs. I am a resller webhost and also put up blogs for businesses and did not have a resource I could go to for helping me with tweaking my blogs for my customers. I have several blogs not that have a load speed problem and with your tips and resources, I have been successful in improving my customer’s blog sites.

  55. Great tips! Can’t wait to see more from you!

  56. [...] 38 Ways to optimize and speed your WordPress Blog [...]

  57. [...] How to host images of your WordPress Website in a Subdomain Speed up WordPress – Ultimate guide to making Sites Super Fast 38 Ways to speed up and optimise your WordPress Blog [...]

  58. Amy Smith says:

    This post was recommended by tech support at BlueHost.  Thanks for the great info.  Hopefully this can solve some of my CPU throttling issues.

  59. [...] tips/38-ways-to-optimize-and-speed-up-your-wordpress-blog/ [...]

  60. [...] 38 ways to optimize and speed up your WordPress blog [...]

  61. Praveen says:

    Your blog’s speed proves that these tips are really working :)
    Thanks…

  62. Thom says:

    I found that by using a new service called cloudflare that not only did my sites speed up but when my host suddenly had trouble with IP addresses the cache version continues to be displayed.

  63. robenvelop says:

    I used this information to speed up my own blog. It really works. Thanks for sharing.

  64. [...] The main reason why you must have a blog is to attract visitors who have similar interests as you……r…and most important…a distributor in your downline. [...]

  65. [...] There was the widows and orphans issue … load speed of your blog is really important. Not only is it frustrating to readers trying to read your post, but Google hates a slow site. And my blog periodically has load speed issues. After calling my host company, and then switching host companies, and then bugging them some more, I resorted to googling how to speed up my blog. WordPress Garage has an excellent post on 38 ways to Optimize and Speed Up Your Blog. [...]

  66. Mike says:

    Great post Miriam,
     
    You have included some excellent points and tips that are sure to speed up anyone’s WordPress site. Have you ever tried CloudFlare? It’s a free CDN/DNS. I managed to half my sites load times using it. It’s also very easy it implement as it has its own plugin.

  67. Mike says:

    not sure what happened then, I didn’t post all that code – strange

    • Don’t worry – I cleaned up the code :)

      As for CloudFlare – I never tried it out because the idea of having all my site’s content being dependent on another service like that made me nervous. Plus, recently I’ve read about sites where CloudFlare not only didn’t speed things up, but slowed them down.

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.

More in Tips (37 of 95 articles)