Maximum performance with WordPress

Ernest Marcinko Tutorials, Wordpress 1 Comment

There is nothing better, than seeing the speed of the fresh “virgin” WordPress installation. After installing few plugins, making posts or loading up the webshop, this speed exponentially decreases. In the end, you get a nice looking website with crappy loading speed. Ruining the user experience with slow speed is easier than you think.

More speed = Less abandonment

There is a nice infographic on kissmetrics about how loading time affects the user experience. Let me break down parts of this infographic for you:

Load times infographics Load times infographics

Those are some devastating facts.

  • 47%!!! expects that your page will load in 2 seconds. This is mad news.
  • However “only” 40% will leave after 3 seconds, but
  • for every 1 second after, you loose additional rough 7% of your original visitors count.

Let me put it this way:

Web-Rage

That’s you when your site is slow.

Today 100 happy people visited your website and if it loads in

  • 5 seconds – you lost around 54 visitors
  • 7 seconds – you lost around 71 visitors
  • 10 seconds – you lost around 92 visitors

before they ever seen your website! As crazy as this sounds, just think about it. How many people would wait for facebook for 10 seconds? At first probably a lot, but after some time most users would switch to another social website like g+ or something else.

What makes my WordPress slow?

There are many factors, but the five with the highest impact on load speed are:

  • Plugins – bad quality or high quantity
  • Lots of dynamic content or HUGE database on a shared hosting
  • Lack of proper Cache
  • CDN and Content compression
  • Blocking client side scripts
 !! But I need my 267 plugins for various important things and stuff !!
My mums IE in the 90's

My mums IE in the 90’s

Nope. You don’t. It’s impossible to have acceptable speed and dozens of plugins at the same time. You should exchange some of your plugins for few lines of code, static HTML preferred. You can see a good example in my previous article about a Stay connected box for WordPress without a plugin.

A few lines of hard coded snippets can save you from the unknown plugin codes – which by the way can be also dangerous (can contain unknown errors).

Plus what if a newer version of WordPress comes out and breaks some of your plugins? You will have to wait for upgrades.

Try to self-code as much functionality as you can. The unnecessary code amount of plugins will slow your site down, a lot.

My store/blog/twitterclone has 123 576 items, and I need them all

Nope. Or if you do, then you should consider porting your SQL server to a redundant host (expensive). Querying hundreds of thousands of records takes time. You need Caching. There are lot of caching solutions on the market, you can read about it in the next chapter.

Don’t forget the golden rule of Quality>Quantity. A few things you can do to make the initial access of your site faster:

  • Create a brief landing page – A static, massively cached landing/intro page saves you a lot’s of database operations
  • Avoid complex queries –  some templates/plugins use very complex queries with no caching to retrieve data from your database. An unoptimized “SELECT .. WHERE content LIKE %xy%”  type of queries with no limits are dangerously slow. Try to use “MATCH AGAINST…” instead with the proper indexes if possible.
  • Widgets with dynamic content – A lot of widgets = a lot of queries = slow page

Check the template and the plugins for unwanted extra database queries, and remove or change them (with caution)

I have all kinds of cache plugins like 5 of them

tumblr_mu5tsrb0Xc1qeu6h3o1_250You only need one at most. I prefer W3 Total Cache, but use the one your prefer. The proper setup is crucial. If you are a small business using cheap shared or vpn hosting you should use:

  • Page cache – saves your database from lots of lots of queries
  • Browser cache – tells your visitors browsers to save some of the assets from your website for later use
  • CDN – next chapter

These are the most basic caching techniques, which are sufficient for most small businesses around there. There are more advanced caching techniques as well, but use them only if you know what they are, and how they work:

  • Object cache – this method is great, however the general “disk cache” (writes/reads data to/from serialized files)  method speed is debatable – I only recommend this if you have Memcached or some kind of Opcode caching mechanism installed: http://stackoverflow.com/a/1013212 
  • Database cache – same as Object cache – only recommended with proper caching mechanism
I don’t need CDN and my Images are small

Nope and You think, but Nope. Your server is on one point on the planet. What if a visitor comes from 3000 miles away from your server? Your server data will travel to his computer through a dozen of connections and will be slow. A proper CDN will help you to resolve this issue by decentralising your data across their network. I recommend one or both of these services:

  • Cloudflare – FREE – not only a CDN but provides protection, minification, Rocket Loader and many more
  • MaxCDN – from 9$ a month – very very fast & cheap

You should also compress all of your assets on your website:

  • Javascript and CSS – W3 total cache has a built in minifier, but it’s most likely that it will result in an error. I recommend only combining the files at first, and minifying step-by step.
  • kraken.io – this image minification tool is just amazing and FREE

 Minify everything that’s possible – images mainly. But be very careful at minifying Javascript and CSS – it often results in an error.

My Javascript is fine, stop this already

pulp fictionAgain, Nope. Scripts (not just) in WordPress are loaded & executed one after another. This is called blocking javascript loading and it’s slow. There are several methods around this, but I only recommend Rocket Loader from Cloudflare. You can read about this here: Rocket Loader for WordPress

That’s it. There is lot more to this topic, but this should be a good starting point for those, who want faster WordPress sites.

Comments 1

  1. Jason

    I disagree that “too many plugins” will bog down your site. Suggesting there’s an arbitrary number (e.g., 24 plugins is good, but 25 is bad) is misleading.

    It’s not about the quantity of plugins, but rather the quality. Are the .js and .css scripts being enqueued properly? Things like that.

    I have a site that has 56 plugins, and *all* pages load in under 2 seconds.

    Lastly, many people think they found a pot of gold when they google their issue and a tutorial tells them to add a snippet of code to their child theme’s functions.php file. But in essence, that’s the same thing as adding a plugin.

    In short, when you’re installing a plugin, look at the reviews; look at what people are saying (or aren’t saying); scope out the author’s other works. Does he/she support the plugin? Does he/she maintain it?

    I do agree, however, that too many people either neglect caching completely (a mistake), or cache too aggressively (a mistake). A caching plugin such as the one you mentioned, W3 Total Cache, will be just fine — although some caching plugins add too much junk to your htaccess, which can bog down your site.

Leave a Reply

Your email address will not be published.