Quick WordPress Optimizing Tips

Last week I sat in on this great A List Apart: On Air event titled  “Designing for Performance” It was their first online-only panel with four great presenters. Along the way I picked up a few tips and tricks I wanted to share with you all.

Here’s a few quick things you can do to improve the performance of your WordPress site.

Introduction

Before we begin, if your site is accessible from the web, punch in its URL into one of the following tools (or both!).

Make a note of the scores you’re given. We’ll compare them at the end.

Use a caching solution

The first thing you can do? Install a caching plugin or setup an in-memory cache. For folks on shared hosts (Bluehost, Hostgator, etc) the easiest (and often only) option will be going with a plugin. My plugin of choice is WP Super Cache.  Why this one in particular? It’s been around for ages, is super easy to use while still being customizable, and it’s authors include Donncha O Caoimh and Automattic. A pretty good pedigree if you ask me.

If you don’t want to do much mucking around, just install the plugin and turn on caching. This will allow your site to serve static version of your pages. This make your site quicker as WordPress (and the PHP/MySQL behind the scenes) doesn’t have generate a new page for each visitor.

Advanced options that I like to use are in the screenshot below. I like to make sure I enable  compressing pages as less data has to get tossed around. “Don’t catch pages for known users.” is handy if you’re an individual editor (or have a small team). This tells WordPress to alway serve up a new page to folks who are logged in to your site. This way you always see your updates without having to clear the cache.

WP_Super_Cache_Advanced

Compress your theme’s images

Let’s say you’re building a theme from scratch, using a child theme, or even just uploading a nice crisp PNG for your site’s header image. In each case WordPress  will use images within the theme to display common elements – like that header image. When these elements appear on every page your site has to serve up that image to every viewer, every time.

One way to speed up your site is to make sure you compress these common images as much as possible. This doesn’t mean degrade their quality with heavy compression like jpg images, but to remove as much metadata and use more advanced compression algorithms as possible.

Side note: Another big win for leveraging smaller images is to make sure you’re not uploading giant images to only have them displayed at small sizes. That’s a whole ‘nother post on its own!

How do you do this? Grab an application like ImageOptim or RIOT.

With either of these apps you can drag and drop in your images and let the tool do its magic. This includes background images, header images, or even icons used across your navigation and widgets.

Here’s an example of a recent optimization from a theme I optimized. This is using ImageOptim. Either tool uses a whole suite of tools behind the scenes to make the best optimization quickly and with great results. imageoptim-example

I saved a whopping 47% on average in this theme. In the case of my background tile image I saved a whole 80%. Not to bad. (Here’s another example with less impressive, but still good, results.)

 

Set up a caching rule

Even with something like WP Super Cache in place you still might need to set up some rules about static content. Static content is things like images, documents, multimedia files, etc.

For these files, WordPress delivers the file for a visitor every time. Even if they leave and come back five minutes later!

The easiest way to do this is to modify your .htaccess file and add a few rules for static content. The .htaccess file tells your site to give folks a locally cached version of the file and to ‘expire’ the item in the cache after so many minutes. This greatly helps in the loading of those (newly optimized) theme images I mentioned in the last tip, and any other files visitors consume on a regular or repeat basis.

I’m going to direct you to this post that has the handy steps on caching static content.

 

Minify your CSS

You’re using a child theme, right? Or maybe a custom theme built from a starter framework? Once your site is ready for production you can shrink your CSS files to make things a little quicker.

Minifying your CSS takes the human-readable version of your CSS file, with all it’s great inline comments and indents, and strips all that junk out. The computer doesn’t need any of that!

Now you’ll want to keep an un-minifed version around for future changes. Take a copy of your style.css file in your theme directory and rename it. Call it style-original.css or something and set it aside.

Now, copy and past the content of your style.css file into a tool like CSS Minifier or CSS Compressor. These tools will strip out any comments or spaces (making your file pretty much unreadable by humans) and reduce the file size (and therefore load times) of your CSS.

Copy the minified CSS back into style.css and save. If you have to make new updates down the road (always in your dev environment first, right?) you can re-load your human-readable CSS file, make your edits, and minify again.

On a few sites I manage I was seeing upwards of 60% file size savings. When were talking about mobile devices in not-so-good coverage areas that could be the difference between your site loading and a visitor leaving.

 

Conclusion

This is just a few things you can do quickly to improve the performance of your site. Making your site load quickly for visitors make them more likely to hang around and helps with your search rankings.

How much of an impact does it make? Remember those tests I asked to your run at the beginning of this post? Here’s a before and after (totally unscientific) comparison to a site I manage. I ran the default tests from webpagetest.org. Just using these tips made one score go from a C to a B and another from an F to a B!

webpagetest-beforewebpagetest-after

If you have tips or tricks you use to make your site’s a little quicker, let me know in the comments below. Thanks for visiting and I hope to see you at one of our upcoming meetups!

Photo by _chrisUK – Licensed under Creative Commons