“Premature optimization is the root of all evil” is a (mis)quotation that anyone who has seriously studied development knows. Coined by Donald Knuth, it’s intended to convey the idea that some optimizations are better than others, and that wasting time on minor optimizations is an inefficient use of time that could be better spent elsewhere. I’m often struck by how much time some WordPress site owners spend working on minor performance optimizations to no great effect, while they ignore major performance optimizations like moving their site to faster hosting. There are many sources of optimization information online, and for the most part they provide advice that is good in theory, but that may mislead site owners into spending undue resources on optimizations that don’t give them the best bang for the buck.
Optimizing for performance is an important part of providing a great user experience. No one likes a slow site. For users, slow sites provide a frustrating experience. And for site owners, they can seriously degrade conversions and engagement — too slow and users will find alternatives or, at the very least, will interact with the site less than they would otherwise.
But site owners should be smart about what they optimize. In a recent blog article, Nate Berkopec discussed a huge performance improvement he’d been able to make on rubygems.org. By changing webfont provider, he slashed the loading time of pages on a crucial part of the Ruby development ecosystem. His optimization was well chosen and informed by hard data about which factors were impacting page load times.
I was recently talking about performance optimization with a well-informed and technically capable WordPress site owner. He told me that in an effort to reduce the load time of his pages, he was rewriting all his theme’s jQuery code in plain JavaScript. To my mind, this is an example of a premature optimization. The jQuery library is a relatively large file which takes a chunk of bandwidth to download. And jQuery is slower than plain JavaScript. Rewriting in JavaScript stands a good chance of making the site load and run a little quicker. The problem is that it is a little quicker and rewriting huge chunks of code on site that uses jQuery extensively will take a long time. The point was driven home to me when I noticed that most of the images on the site in question hadn’t been optimized — they were at least 30% bigger than they needed to be. Installing an image optimization plugin or pre-optimizing images before uploading would have had a significantly greater effect on performance than the JavaScript rewrite, and it would take a fraction of the time.
Efficient performance optimization requires performance testing to guide site owners to the points in the loading process that have the most influence on load times. Focus on the areas that will have the greatest impact. Your browser’s developer tools and performance testing sites like WebPageTest and Pingdom Tools are your friends.
I’ll end with a word of warning — “premature optimization is the root of all evil” is sometimes used as an excuse to not optimize for performance at all, or to avoid optimization tasks that would have a substantial benefit but that would take a lot of work. My point here is not that WordPress site owners should ignore performance optimization, but that performance optimization efforts should be intelligently focused where they have the most benefit.