These past 2 weeks at work, I’ve learned a lot about optimization; you could say it’s been a “reality check.” Last week, I took time to check response times on websites we host on Godaddy. Taking the plain HTML+CSS times as a baseline for size, resources & speed (very fast), I started to wonder what was causing the lag on WordPress sites. Answer? The CPU. Turns out most servers run overloaded, and CPU cycles are vastly more expensive/taxing than mere file-access, or even a surprisingly chilled-out database server. But the big takeaway was how expensive the CPU cycles were over-and-above the network calls. CDNs are your friends folks! And so is caching to plain-HTML-files. Word to the wise.
Today, I stumbled upon another metric: lines of code. This used to be a huge metric in software development, but then somewhere along the way it has become forgotten, especially among “just throw in another widget or plugin” WordPressy folk. More widgets, more plugins = more RAM & CPU on that overloaded server, right?
Turns out that I’m in the habit of using 20-40 plugins per site! Nevermind the other 20 features I’ve added in with the functions.php file. For the latest site, the theme was running 5500 lines of code, but the plugins were up around 360,000 lines! That’s 7200 single-spaced pages in Word, and that’s insane. My 4-website average is luckily half of that number, but it’s still too much. I think I’m going to have to go on a slash-and-burn rampage against my own work.
Perhaps you’re wondering why I hadn’t come across this sooner, or that I’m new to all this. The sad truth is that I’ve been developing sites for 5 years now, and only NOW do I have both the interest and the time to focus on these things. I’ve probably made 20 sites, but they’ve all been in small-business, in single-developer environments: not the best learning curve. There are some other blogs out there that unscientifically guess at solutions, but when web-hosts promise the world, but give zero log-access (aka no feedback) and won’t tell you how much horsepower is (a) available or (b) being used.. how am I to know? Not all our clients can afford dedicated hosting plans, but maybe I should start asking if they’re looking for that extra 200 milliseconds off their load-times.
Some tools I found handy: