Turbocharge your WordPress Speed!
WordPress is an amazing platform that powers over 28% of the world’s websites and growing. It’s ease of use (relatively) and modular framework gives a voice to bloggers, start ups, and enterprise level businesses like no CMS before it. WordPress speed however, is the all too familiar curse for most businesses. It doesn’t take long for a fresh install to become a bloated mess with plug-ins, giant images, and heaps of external requests.
In putting together Pixel Leak I spent hours and hours of research time into finding the best possible solutions, at the best possible price (free!), to make it load like a rocket ship. I leaned heavily on others work and I’ll make sure to link the sources as we go along. I’m proud to report that I was able to take my site load time from closer to 3 seconds down to nearly 0.5 seconds overnight. Here’s how I did it.
The quickest and most free option is to simply change your PHP version. In my article here, I walk you through changing from PHP 5.6 to PHP 7.0. Doing that alone cut my load times anywhere from 900ms to 500ms depending on who I tested with. Milliseconds might not sound like much, but they add up very quickly into real, perceivable speed improvements.
Our next step is still easy and still very free. On GoDaddy cPanel servers you have the option to compress data before it get’s sent out out to a browser. On your cPanel menu type “optimize” into the search bar. Next, click on “Optimize your website.
In here, you can select to compress either ALL content or certain types you specify. I chose to compress all content.
So with PHP switched over to version 7.0, and Apache compressing content before it serves it to the browser, my speeds dropped down to the 900ms range. So far, not too shabby for spending zero dollars and about 5 minutes of my time.
Now we get to start playing with the fun stuff. WordPress generates each page dynamically every time a visitor goes to a page. This requires your server to get the request for a page, go look in the database for content, process all of this, then send it to the browser to be viewed. Wouldn’t it make more sense just to serve an HTML page for static content like blog posts and other pages? Yes it would, and that’s where caching plug-ins come into play.
I decided to start with WP Super Cache based on reviews and ease of use. W3 Total Cache is another popular option in the WordPress speed freak community. I activated the plug-in with just defaults following the installation instructions. Once I verified the cache was full, I ran another speed test.
I was Super (heh) happy with the results on this run. My goal is to get down to half a second, or 500ms, and we’re nearly there! When reviewing the suggested improvements I could make, I did notice some stubborn areas that wouldn’t go away. Namely, the Google Analytics call to Google’s servers every time a page is loaded.
Nerd Hat Required Beyond This Point
So, I wanted to know how to get rid of that external call from Google, but I wasn’t sure how to keep my tasty analytics without it. So…I Googled the problem and found the perfect solution. I won’t repost this amazing article I found that walks you through it, but I’ll try my best to sum it up.
You’ll be downloading the Google Analytics script and create a file on your server to put it into. Next, you’ll be creating another file, this time a PHP script, that when ran will automatically go out and fetch the current analytics code (apparently this changes often) and update the first file. Finally, you’ll create a cron job (automagic stuff) that runs the PHP script daily and updates your first file all on it’s own!
Now that we’re calling the script internally from our own server instead of pinging Google every time, we are ever closer to the half second load time!
Smush those .jpgs
The last step I took in optimizing (for now) was my images. I had already tried my best to save at the appropriate quality and size but I knew there had to be some more wiggle room. I decided to go with WP Smush to see if I could squeeze out a few more kb from their file size. After installing the plug-in I just went with their bulk smush option, this will take all of the existing files on the server and compress them.
One megabyte might not seem like much in nowadays, but you want your site to be as lean as possible for load times, especially WordPress speed loading. The great thing about the plugin is it will automagically compress future image uploads too.
Let’s See that WordPress Speed!
So after paying zero dollars, and maybe an hour or so of my time (not counting research or rebuilding cache), I was able to shave nearly 2 entire seconds off my site loading time. That’s HUGE (err..small?)!!! I didn’t hit my goal of 0.5 seconds, but I would say I got damn near close. I’ll make sure to do an update in the future if I’m able to squeeze some more performance out of this shared hosting plan.
p.s. I did not end up using a CDN for these tests as I wanted to see how lean I could make the site first. I’ll look into a CDN solution like CloudFlare later and do more testing.