MCS:PHP:CSSLib
From MozillaWiki
CSSLib
CSSLib is a small PHP library that allows to operate and manipulate on CSS files.
It contains:
- full DOM lvl 2 Style Binding implementation
- CSS parser
- CSS serializer
- CSS optimizer
Usage patterns
Simplest usage pattern is to tie it into your PHP code in order to offer caches CSS file in place of multiply source CSS files.
Example implementation
<?php $cssFiles = Array( './css/core.css', './css/skeleton.css', './css/layout.css' ); @include_once('../lib/csslib/optimizer.php'); $cacheFile = './css/mcs.css'; if (class_exists(CSSOptimizer)) { CSSOptimizer::printFromCache($cssFiles, $cacheFile, $level=5); } else { foreach ($cssFiles as $v) { ?> <link rel="stylesheet" href="<?php echo $v?>" type="text/css" media="screen" /> <?php } } ?>
This code will try to use CSSOptimizer if possible or will print normal CSS links.
CSSOptimizer will try to build mcs.css cached file and use it (with level=5 optimization) but if it fails it will also produce clean list of links to source CSS files.
Sources
CSSLib sources are here.