CSS compression

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
ozzy
New Member
New Member
Posts: 4
Joined: Fri Sep 19, 2008 3:54 pm

CSS compression

Post 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
JeremyBASS

Re: CSS compression

Post 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...
User avatar
Augustas
Forum Members
Forum Members
Posts: 241
Joined: Wed Oct 17, 2007 6:09 pm

Re: CSS compression

Post by Augustas »

This website is also explaining how to compress css and javascript:

http://rakaz.nl/item/make_your_pages_lo ... _css_files
http://FollowTheRoad.com/ - living on the road...
http://www.kligys.com/ - asmeninis blog'as...
Pierre M.

Re: CSS compression

Post 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.
Post Reply

Return to “Tips and Tricks”