PHP Class Minify_CSS, minify

This is a heavy regex-based removal of whitespace, unnecessary comments and tokens, and some CSS value minimization, where practical. Many steps have been taken to avoid breaking comment-based hacks, including the ie5/mac filter (and its inversion), but expect tricky hacks involving comment tokens in 'content' value strings to break minimization badly. A test suite is available.
Author: Stephen Clay ([email protected])
Author: http://code.google.com/u/1stvamp/ (Issue 64 patch)
Mostra file Open project: mrclay/minify Class Usage Examples

Public Methods

Method Description
minify ( string $css, array $options = [] ) : string Minify a CSS string

Method Details

minify() public static method

Minify a CSS string
public static minify ( string $css, array $options = [] ) : string
$css string
$options array available options: 'preserveComments': (default true) multi-line comments that begin with "/*!" will be preserved with newlines before and after to enhance readability. 'removeCharsets': (default true) remove all @charset at-rules 'prependRelativePath': (default null) if given, this string will be prepended to all relative URIs in import/url declarations 'currentDir': (default null) if given, this is assumed to be the directory of the current CSS file. Using this, minify will rewrite all relative URIs in import/url declarations to correctly point to the desired files. For this to work, the files *must* exist and be visible by the PHP process. 'symlinks': (default = array()) If the CSS file is stored in a symlink-ed directory, provide an array of link paths to target paths, where the link paths are within the document root. Because paths need to be normalized for this to work, use "//" to substitute the doc root in the link paths (the array keys). E.g.: array('//symlink' => '/real/target/path') // unix array('//static' => 'D:\\staticStorage') // Windows 'docRoot': (default = $_SERVER['DOCUMENT_ROOT']) see Minify_CSS_UriRewriter::rewrite
return string