Use CSStidy to minify CSS file if using caching
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Apr 2009 22:39:09 +0000 (16:39 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Apr 2009 22:39:09 +0000 (16:39 -0600)
Big-time improvement in CSS filesize, *especially* if using a theme that
overwrites the base theme - instead of including declarations twice,
CSStidy will only write the final calculated value.
For example, the base dimp page with the silver theme using the old
caching method generated a 161 KB file. Running through CSS tidy
generates a 96 KB file.

imp/lib/IMP.php

index 7c6c739..14737d8 100644 (file)
@@ -1662,6 +1662,13 @@ class IMP
                     $out .= $tmp;
                 }
 
+                /* Use CSS tidy to clean up file. */
+                require_once HORDE_BASE . '/services/csstidy/class.csstidy.php';
+                $css_tidy = new csstidy();
+                $css_tidy->load_template('highest_compression');
+                $css_tidy->parse($out);
+                $out = $css_tidy->print->plain();
+
                 switch ($cache_type) {
                 case 'filesystem':
                     register_shutdown_function(array('IMP', 'filesystemGC'), 'css');