When your website is getting alot of traffic, you’ll eventually reach the point where you want to tune things (or good habits). Next to backend and frontend caching, checking your expiry headers, optimizing images, … you can also minify your application’s output. Minifying or ‘minification’ is ‘the process of removing all unnecessary characters from source code, without changing its functionality‘.
Now keep in mind, it’s always better to load your CSS from an external stylesheet, this way it can get cached + you can use a very cool tool called http://code.google.com/p/minify/ . This leaves us with all the other code, your website’s HTML.
Create a new view output helper (more about this):
class My_View_Filter_Minify implements Zend_Filter_Interface
public function filter($value)
return Minify_HTML::minify($value, array(
'cssMinifier' => array('Minify_CSS', 'minify'),
'jsMinifier' => array('JSMin', 'minify')
Next and final step is letting our project know we want to use this new filter globally, so add the following code in your bootstrap:
public function _initMinifyHTML()
$view = $this->getResource('view');