In the early 2000s, heading into the first decade, there were a few common pieces of wisdom that everyone accepted when it came to speeding up your site for CSS, JS, and HTML:
- Minify EVERYTHING
- Combine EVERYTHING
Modern day best practices have come a long way since then. HTTP/2 came a while back, and HTTP/3 is just around the corner. And presumably, there’s a lot more to come after that. These new technologies, along with increased universal bandwidth, have greatly changed what the “best practices” are. For example, last year I wrote about how the practice of combining JS and CSS is outdated.
But what about minification? Is this something that’s still valuable? Let’s see.
Pre-Minified Libraries are the Best
The best-case scenario is that you’re using a public library like jQuery that’s already minified. This can actually result in quite significant savings, especially when you consider the size of something jQuery. Here’s a comparison of normal vs minified jQuery sizes computed from Google’s public library:
- Size of jQuery original: 288 kb (Link to original jQuery)
- Size of jQuery minified: 94 kb (Link to minified jQuery)
In a way, the question of minification for optimization has become moot because the most impactful assets have already been minified!
Un-Minified Assets Might Not be Worth Minimizing
But the size of this file is only 4 kb! In today’s world of high Mbps bandwidth, I’m not entirely sure it’s even worth minimizing a 4 kb file. After minification, it would be 2.7 k.
Remember, that manual minification comes at a slight cost. Your server has to first perform the minification, and some plugin has to include a hook that replaces the original JS with the minified one. All for saving a few KB?
Not worth it, in my opinion.
What About Minifying HTML?
If you want to go down the road to the end, you’ve probably encountered the option of minifying your HTML too! But this is where I draw the line. While the value of minifying plugin JS or CSS is questionable, I think minifying HTML is actually harmful for these reasons.
1. HTML Changes Frequently
Since any minification takes server resources, it’s worth minimizing only those assets which are relatively unchanging like CSS and JS. HTML changes too frequently to be worth it IMHO.
2. HTML Pages Are Too Numerous
At most, there are only a handful of JS and CSS files on your site, and some of them won’t even be loaded each time. A typical site on the other hand, can easily have hundreds of HTML pages. Minifying them all, and then invalidating them when you simply add another post is just too much effort.
Not to mention the file clutter of storing hundreds of copies of minified HTML pages. Cloudflare offers to do this for you automatically, but I just disable that option.
Minification is no longer this “must do” thing that website owners have to worry about. That’s not to say it isn’t useful – it is! Just that most of the low hanging fruit has already been plucked by pre-minified files, and there’s not much left for web owners to do. You can try and manually minify your JS and CSS files that haven’t already had the process applied to them, but it’s not worth it in my opinion. And HTML minification? Give it a pass!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply