CSS compression with own PHP class VS CSSTidy - Comment Page: 1

It makes sense to optimize the site's cascading style sheets (CSS), as it pages load faster, and it reduce the amount of data transferred, and just combining css files could significantly reduce requests to server. So users benefit from faster page loads and webmaster of the sites benefits from the cheaper price of the transferred data. I have used CSSTidy on many projects. And CSSTidy is very good tool for packing CSS and it can even fix CSS errors. Sometimes, however, feel that csstidy is even a bit too wide and "heavy" tool for the CSS files packing. Thats why I decide to write my own simple PHP class for the CSS files packing. I did some tests and it appeared that actually all the...

5 comments on “CSS compression with own PHP class VS CSSTidy - Comment Page: 1

      • One moment.
        Conflicts with an asterisk “*”. For example in the presence of such structures – “*{}*” will conflict.

        To avoid this, we must at the very end, add:
        $patterns[] = ‘/\*\{/’;
        $replacements[] = ‘ *{‘;
        $patterns[] = ‘/\}\*/’;
        $replacements[] = ‘}* ‘;

    1. Very good, indeed!
      There’s only one thing missing, and that is to replace ;} with just }

      Thanks a lot!

    2. Awesome thanks for the script I use it with Concrete5 to get my site load faster.

    3. maybe you should remove last ; of row:
      a{color:red;background:green;} => a{color:red;background:green}


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.