Basic WordPress Speed Optimization

I am meticulous about the load speed of my clients websites, and would love to hard code every website for complete control over the content – but that is not a reasonable expectation with the requirements of businesses today and the expectations of their customers.

WordPress is the preferred platform for small business websites and blogs. It’s lean, it’s fast, and you can do just about anything with it. There are thousands of plugins available, and this is where most sites make large speed concessions.

By using many of the themes and plugins available for WordPress, you are choking your server and adding hundreds of useless images and lines of code. The coding practices used by some theme developers are rudimentary. Developers and designers who are in the process of honing their skills build themes for experience. I admit, it is an excellent way to progress – but everything they create is not fit for human consumption.

This article will cover 8 aspects of speed optimization:

  1. Caching Plugins
  2. jQuery by CDN
  3. Plugins
  4. CSS and Stylesheets
  5. Page Rendering
  6. WordPress Optimized Hosting
  7. Use a CDN
  8. Tools & Testing

Install a Caching Plugin

A caching system will create static versions of your pages the first time their requested. The next time the cached page is requested your server won’t need to run complex queries and functions to create the page from scratch. Your sites speesd can increase dramatically with a caching system and you can better handle traffic spikes.

Recommended plugin: WP Super Cache
Avoid: W3 Total Cache – this is a solid system if you are an advanced user with advanced requirements. Novices should avoid as setup is tricky and you need 1% of the features offered.


Serve jQuery from a CDN

The majority of websites today use jQuery, and it’s included by nearly every WordPress theme. When a user visits your website, their browser is required to download your copy of jQuery instead of using a cached version. You can change this by serving jQuery from Google’s CDN (?).

By using Google’s CDN your visitors are likely to have a cached copy and won’t need to download it.

How to use Google’s CDN to serve jQuery:

  1. In your themes folder, open functions.php
  2. Add the following lines to the bottom::
    if( !is_admin()){
       wp_deregister_script('jquery'); 
       wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"), false, '1.7.1'); 
       wp_enqueue_script('jquery');
    }

Note: replace the version number with the version of jQuery you are currently using.

Use Microsoft’s CDN:

In the Google example above, replace:

http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"

With:

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js

Disable plugins

You may have plugins that you do not use, or which do a simple task that could be coded into your theme. Perform an audit of your plugins and disable as many plugins as possible.

The main problem with plugins is that anyone can create them. Their database calls and coding are often inefficient. Small sites won’t notice the performance hit, but if you have a large site just one inefficient query could bring you down.


Combine CSS stylesheets

Plugins necessary for your site may be loading their own CSS files. Inclusion of multiple stylesheets adds overhead to your visitors and your server, and is generally a bad practice. You can disable the output of the plugins stylesheet and copy the styles to your main css file.

How to combine CSS stylesheets

Check your website to see which plugins may be including a stylesheet. Do the following for each:

  • Open the plugins CSS file. Copy the CSS rules into your themes stylesheet.
  • Download the plugins files from /wp-content/plugins and perform a search for:
    wp_register_style

    You will find a line similar to:

    wp_register_style(  'syntaxhighlighter-theme-default',    plugins_url('syntaxhighlighter/' . $this->shfolder . '/styles/shThemeDefault.css'),    array('syntaxhighlighter-core'), $this->agshver );
  • Place the following function in your functions.php:
    function my_deregister_styles() {
    	wp_deregister_style( 'syntaxhighlighter-theme-default' );
    }

Check your theme – the plugins stylesheet should no longer be loaded.


Page Rendering

Optimizing your CSS and html can go a long way to the perceived speed of your site. Read Google’s article on Optimizing browser rendering to learn more.


WordPress Optimized Hosting

Basic shared hosting is not suitable for income generating websites – you need an environment with guaranteed resource availability. There are several hosts that deliver exceptional performance to WordPress blogs:

  1. WP Engine

    Highly optimized hosting – probably the best in the business. They optimize your installation with their own plugins and all of their packages also include usage of their CDN. Starts at $49.99/month

  2. Page.ly
    These guys are good, and on the same level as Wp Engine but they really need to work on their marketing strategy more. Skip them if your looking at the $19.95 plan.

Now many people would say “just buy a VPS” if your looking to spend over $50 a month. Truthfully, the services the above companies provide is exceptional. They allow the average person to host in an environment optimized for WordPress without touching linux and even provide WordPress support.


Use a CDN

There’s a million reasons to use a CDN. To make it even easier, our favorite caching plugin WP Super Cache allows you to start using a CDN with just a couple clicks of your mouse.

My favorite CDN’s:

This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *