Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Add code compressors to fTemplate

posted by earth 9 years ago

It would be nice if fTemplating had a compressing feature to compress JS, CSS and (X)(H)TML code automatically/on demand. The result code would be cleaned from all the unnecessary content, such as spaces, comments, etc. and we should be able to cache this code.

I've considered adding some basic minification for CSS and JS, however the topic gets complicated very fast. To do this properly you have to have full parsers for each type. For instance, in JS is is perfectly valid to leave off ; at the end of lines, but the code will break if naively minified. HTML is even more complex due to issues with whitespace, and some IE-specific HTML comments.

Probably one of the simplest steps is to configure your web server to gzip encode HTML, CSS and JS. That will get you a significant amount of bandwidth saving. Beyond that you'd probably need to look into technology-specific compressors.

posted by wbond 9 years ago