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.
[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:
- First, define a goal, such as reducing page load time from 8 seconds to 2 seconds.
- 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.
- Use Pingdom to get a detailed analysis of your blog’s loading time and performance.
- See what your browser is doing with tools like Firebug’s network tool, Charles Proxy or Wireshark, and review the server logs.
- 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.
| View | Upload your own
Reduce the number of dynamic PHP and http calls:
- “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.
- Use different host names to increase the number of active download threads.
- 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.
- 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
- Optimize your image files for the web.
- Make sure that all images have height and width tags.
- Consider hosting your images on an external site like flickr that has huge servers and can handle the load.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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;}
- 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.
- Validate your code at W3C to make sure you don’t have any major errors slowing down your page.
- 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…
- 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
- 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.
- 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(); } ?> - 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
- Use phpMyAdmin to optimize your database: Log in to phpMyAdmin, select all the tables, and then “repair” and “optimize.”
- 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).
- Use the Optimize DB plugin to optimize the tables of your database.
- Use WordPress Plugin: Fix Database to check all tables in your database and fix any errors.
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Some more caching possibilities: MySQL query cache, PHP Compiler Cache. Learn more here.
- 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.
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
Diggproof & Speed up Your WordPress Blog
WordPress Optimisation: Control When Plugins Are Loaded
Also published on Medium.
Pingback: Ultime dal fronte WordPress 17-2008()
Pingback: WordPress Weekly News, 17-2008()
Pingback: WordPress is a CPU hog - use caching plugins! | WordPressGarage.com()
Pingback: Caching enabled - kleines Update für Planet iQ » think twice & have fun!()
Pingback: Fatih Hayrio?lu'nun not defteri » 26 Nisan web’den seçme haberler » Metin, alan?, de?er, önerme, i?ini, yard?m?, Ba?lant?, Javascript, için, anlat?ml?()
Pingback: Come ottimizzare la velocità di caricamento di un blog wordpress | daniele rollo()
Pingback: [ fatih hayrio?lu ]26 Nisan Seçmeler « CSS Ar?iv()
Pingback: 38 ways to optimize and speed up your WordPress blog | Anidan Design : eco-friendly web & graphic design()
Pingback: 25 formas de optimizar e acelerar o seu blog Wordpress | Fique Rico Online()
Pingback: Optimize WordPress install and save webhosting dollars! | Blog Design Studio()
Pingback: Easy Steps To Speedup Your Wordpress Blog : Cloud Four()
Pingback: Caching enabled - kleines Update für Planet iQ - Der Webanhalter()
Pingback: Poll result : 55% bloggers pay less than $10 on hosting! | Blog Design Studio()
Pingback: Caching enabled - kleines Update für Planet iQ « Der Webanhalter()
Pingback: How To Speed Up A Sluggish Wordpress Site | WP-Blogger()
Pingback: New Wordpress Install: Things I Learned Along the Way | Outpt.()
Pingback: Web design is fun, but you should really focus on producing content. | My Webmaster Tips()
Pingback: Speeding up your WordPress website, another take « Web Page Authority Blog()
Pingback: Link Post for January 9th through January 11th()
Pingback: Bookmarks for January 9th through January 11th | Philadelphia Social Media Marketing()
Pingback: A Few Ways To Speed Up Your Blog | Graphic SEO (dot) ORG()
Pingback: WordPress Quick Speed Optimizations()
Pingback: Beneath a Steel Sky » Lättnaden och lyckan av ett fungerande hem()
Pingback: Resources for Blogger Gadgets | GeneaBloggers()
Pingback: How to: optimize wordpress blog for maximum speed()
Pingback: How to Speed Up Your Wordpress Site()
Pingback: Where are They Hosting? — Happy Hotelier()
Pingback: How to resize images for your blog()
Pingback: Speed Up Your WordPress Site | Anthony DeBarros()
Pingback: Site speed tools and 15 tips | Affiliate Marketing Journey()
Pingback: Speed up Wordpress | 2Dpixel.com()
Pingback: Why All Network Marketers (YOU) Must Have a Blog — RonChordigian.com()
Pingback: The Backside of the Blog: How Not to Blow Up Your Blog : PragmaticMom()