Yes, it is that time again. I love WordPress to death. Yet sometimes I find it a bit silly. There must be a solution to this gripe at the very least because somehow, Facebook and many other huge sites solved it.
The Gripe
It’s about CSS and Javascript. It’s about how just about every CSS and Javascript file is hosted locally and therefore should be compressed. I notice many plugins run with a particular version of jQuery, Mootools or Prototype. We can make an exception for those but why aren’t other scripts and stylesheets being minified?
The Way to Fix It
The way to fix it is to have a function accept an argument that will slurp up all of the requested css or javascript and subsequently put it in one file and then compress the life out of it. My child theme’s style.css ran about 17kb before I compressed it, it came out as 12kb after whitespace annihilation. It would be unbelievable if that had made a significant difference, it doesn’t. However, my theme consists of more than just my style.css, it uses other @import directives to include other files which means there’s still an extra 30kb of css somewhere going uncompressed.
Actually, the way to fix it already is out there. The front-page example of Minify compressing WordPress assets! WordPress already has the wp_enqueue_script function which will include a script tag to a specific url in the head. A function similar to this could do the minifying.
The Grim Reality
I realize that compressing and caching stylesheets and javascript files isn’t the final solution. The big slow down is HTTP requests. My plugins and theme send out 24 separate HTTP requests and I think that is too many. I could live with, at most, ten for a regular blog page. If it were a gallery blog or a ajax powered blog, I’d think differently but as my blog focuses on code and an image here or there, I think 24 is too high.
So that’s about it for now. I hope that the WordPress developers address this in the next version, 2.9.