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:
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:
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 !!
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
You 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:
- kraken.io – this image minification tool is just amazing and FREE
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.