Speeding up WordPress

Posted on May 25th, 2010 in News by Tim Bowen

Tim Bowen’s Speeding up WordPress 5/25/10 presentation

Test load times/elements here: Pingdom
Also use YSlow and Google Page Speed to test speed.

PHP Query Elimination:
Use this: <meta charset=”UTF-8″ />
Not this: <meta charset=”<?php bloginfo( ‘charset’ ); ?>” />

Use Google hosted JQuery / Prototype libraries by adding this to functions.php file:
function my_init_method() {
wp_deregister_script( ‘jquery’ );
wp_register_script( ‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js’);
}
add_action(‘init’, ‘my_init_method’);

Remove actions for WordPress meta, rsd_link and wlmanifest by adding these lines to functions.php:
remove_action(‘wp_head’, ‘wp_generator’);
remove_action(‘wp_head’, ‘rsd_link’);
remove_action(‘wp_head’, ‘wlwmanifest_link’);

Use Google minify for JS and CSS files.
Add Javascript files to bottom of page for faster load speeds.

Define elements in wp-config.php file:
define(‘ENABLE_CACHE’, true );
define(‘WP_ALLOW_REPAIR’, true);

Set the WP URL and Site URL to improve site performance.  Make sure these are same as in the General Settings page
define(‘WP_SITEURL’, ‘http://SITENAME.com/cms’);
define(‘WP_HOME’, ‘http://SITENAME.com’);

Set the template directory and stylesheet directory to improve site performance and eliminate server queries
define(‘TEMPLATEPATH’, ‘/home/public_html/cms/wp-content/themes/THEMENAME’);
define(‘STYLESHEETPATH’, ‘/home/public_html/cms/wp-content/themes/THEMENAME’);

Use optimized .htaccess file

Disable hotlinking with this code in .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/.*$ [NC]
RewriteRule .*\.(gif|jpg|png|ico)$ – [F,L]
</ifModule>

Image hosting off-site with WP-Offload plugin and Steady Offload

Add <?php flush(); ?> after the </head> and before <body> to speed up loading.

Potentially useful plugins:

  • DB Cache Reloaded (small speed bump while helping to eliminate queries to server)
  • W3 Total Cache (small speed bump, also good for heavy traffic)
  • Quick Cache (small speed bump, good for heavy traffic)
  • WP Super Cache (didn’t notice speed bump, reviews claim good for heavy traffic)
  • PHP Speedy (compresses scripts from plugins, small speed bump)