Content Compacter


I’ve created a wrapper extension to a class that minimize bandwidth usage when parsing output to clients.

Made this mostly out of interest so haven’t used this in any large-scale applications yet but i can definitely see some benefits of having this in future projects.

Content Compacter removes unnecessary whitespace, intendents and rowbreaks in your rendered viewfiles. It also compresses inlined CSS and JS in your HTML using borrowed code from minify. It can also remove HTML conditionals specific to IE when detected browser isn’t IE.

For examples and download, click here and i shall magically transfer you to the extensions page! :rolleyes:


Edit: I stripped out a few methods from the original class because they were not the Yii-way to do it. Especially their implementation of gzip output, i’ve seen better solutions and extensions to this, which also is a perfect way of saving even more bandwidth.


I think it’s better to put a space instead of empty string in the second argument.

Like this:

return str_replace($this->_options[‘line_break’], ’ ', $html);

You’ll see why if you use the default template (or any other, but it is also possible to see on the standard).