I'd like to discuss the issue of compression and minification of text resources (e.g. HTML, CSS, JS).
With regard to compression I had a look at available possibilities, and it's simplest to let the webserver do that. For instance, for Apache 2 the following in a .htaccess in the web root might suffice:
Code: Select all
<IfModule deflate_module>
<IfModule filter_module>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript
</IfModule>
</IfModule>
A more portable alternative would be to do the compression with PHP, but I'm not sure how to handle that best. zlib.output_compression seems to be recommended, but that wouldn't play well with output_handler which might be used in some configurations. Anyhow, this would not work for JS and CSS files, for instance, because these are not delivered by PHP.
With regard to minification I'm even less sure what to do. For JavaScript it seems sensible to already deploy minified scripts. However, that's probably no option for stylesheets, as these should be editable from the back-end. And the generated (X)HTML can't be minified in advance, anyway. Searching the web I found loads of short PHP snippets which were supposed to minify HTML and CSS (for plugins.css), but they seem to be broken by design resp. relying on certain conventions. Tidy is probably no option, because it removes conditional HTML comments (IE). There are several libraries which would allow minification, but I can't comment on them, and I'm not convinced that there would be huge savings by minifying before compressing.
Any thoughts?