v1.0.0 2015-07-19 14:21 UTC

This package is auto-updated.

Last update: 2024-04-17 23:15:23 UTC


README

YACM is a lightweight, but effective, CSS minifier. It is slightly different from other minifiers in that it preserves the approximate vertical structure of the original CSS - so unless the formatting of the input is very unusual, the output should be just about readable.

The code is unit-tested and can be installed using Composer.

This code is based on a Gist of mine.

Basic Usage

use Danbettles\Yacm\Minifier as CssMinifier;

//@todo Load the library.

$minifiedCss = CssMinifier::minifyNow('body { font-size: 1em; }');

//Or

$cssMinifier = new CssMinifier();
$minifiedCss = $cssMinifier->minify('body { font-size: 1em; }');

Use with BundleFu

You can minify the CSS bundled by BundleFu by calling YACM in a CallbackFilter filter.

//@todo Create bundle as per Dots United's instructions.

$minifyCssFilter = new \DotsUnited\BundleFu\Filter\CallbackFilter(function($content) {
    return \Danbettles\Yacm\Minifier::minifyNow($content);
});

$bundle->setCssFilter($minifyCssFilter);

//@todo Continue using bundle as per Dots United's instructions.

If you need to add multiple CSS filters to your bundle then follow Dots United's instructions on creating and using a filter chain.

Installation

Install using Composer.

composer require danbettles/yacm:dev-master