cssmin reduces the size of stylesheet definitions by removing all unneeded whitespaces and comments.
Nothing special but has the same syntax as jsmin.
Requirements:
- PHP 5.x
Syntax:
string cssmin::minify(string $css, mixed [$options])
- $css = stylesheet definitions as string.
- $options = array or comma separated list of options.
Options
- remove-last-semicolon: Removes the last semicolon in the style definition of an element (activated by default).
- preserve-urls: Preserves every url defined in an url()-expression. This option is only required if you have defined really uncommon urls with multiple spaces or combination of colon, semi-colon, braces with leading or following spaces.
Example:
include("cssmin.php");
// without options
file_put_contents("path/to/target.css", cssmin::minify(file_get_contents("path/to/source.css")));
// with the options remove-last-semicolon and preserve-urls
file_put_contents("path/to/target.css", cssmin::minify(file_get_contents("path/to/source.css"), "remove-last-semicolon,preserve-urls"));