wikimedia/minify
Minification of JavaScript code and CSS stylesheets
wikimedia/minify

Minify is a PHP library for minification of JavaScript code and CSS stylesheets.

Quick start

Install using Composer, from Packagist.org:

composer require wikimedia/minify

Usage

$input = '
function sum(a, b) {
// Add it up!
return a + b;
}
';
$output = JavaScriptMinifier::minify( $input );
// Result:
// function sum(a,b){return a+b;}
$input = '
.foo,
.bar {
/* comment */
prop: value;
}
';
$output = CSSMin::minify( $input );
// Result:
// .foo,.bar{prop:value}

Contribute

See also

Wikimedia\Minify\JavaScriptMinifier
JavaScript Minifier.
Definition: JavaScriptMinifier.php:45
Wikimedia\Minify\CSSMin
Transforms CSS data.
Definition: CSSMin.php:30