Page 1 of 1

CSS compression

Posted: Thu Oct 02, 2008 8:05 am
by ozzy
Loading time of a website is as important as its functionality  8) Edit stylesheet.php in root. On the end of file is something like this:

echo $css;

Replace that with line:

// Compress CSS output
echo str_replace('; ',';',str_replace(' }','}',str_replace('{ ','{',str_replace(array("\r\n","\r","\n","\t",'  ','    ','    '),"",preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!','',$css))))); 
//echo $css;


Thank's to http://davidwalsh.name/quick-easy-css-c ... -using-php

Re: CSS compression

Posted: Thu Oct 02, 2008 3:21 pm
by JeremyBASS
There is some thing called speedy php ... I think... it does this ... CSS and js both... that may be a good add on with this for parts of a CMSMS cache system... till then nice post...

Re: CSS compression

Posted: Thu Oct 02, 2008 6:20 pm
by Augustas
This website is also explaining how to compress css and javascript:

http://rakaz.nl/item/make_your_pages_lo ... _css_files

Re: CSS compression

Posted: Fri Oct 03, 2008 5:05 pm
by Pierre M.
If I understand well this line strips out redundant spaces, tabs and so. Hence I doubt it provides much benefit to a gzip output compression enabled webserver. Worse : it takes additional CPU time to launch and run another string prossessing engine.
Notwithstanding that routers themselves may compress flows I'm curious to see an actual performance comparison.

Pierre M.