PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

PHPMaster.com: Automatic CSS3 Prefixer and Compressor

Note: This article was originally published at PHPDeveloper on 21 March 2012.
PHPDeveloper

On PHPMaster.com today there's a new tutorial showing how to use a little PHP magic to compress your CSS automatically.

There are many ways to compress CSS files or automatically generate browser-specific CSS3 prefixes, but usually extra tools are used which is very annoying. I'd like to show you how such tasks can be done using only PHP.

Complete code for this small script is included in the article. It uses some regular expressions to parse the CSS and does some replacement and removal of things from the CSS content to slim it down and format it all as one line. There are some images illustrating the process also included.