PHP Package for minify HTML code.
Special Thanks: Funtime Team.
You will need Composer installed.
composer require gulch/minify
$minifier = gulch\Minify\Minifier::createDefault();
// default optimizations are: whitespaces remove, html comments remove, minification of css and js code
// above code is equivalent to:
// $minifier = new gulch\Minify\Minifier(
// new gulch\Minify\Processor\WhitespacesRemover,
// new gulch\Minify\Processor\HtmlCommentsRemover,
// new gulch\Minify\Processor\InlineCssMinifier,
// new gulch\Minify\Processor\InlineJavascriptMinifier,
// );
$minified_code = $minifier->process($code);
$minifier = new gulch\Minify\Minifier(
new gulch\Minify\Processor\WhitespacesRemover,
new gulch\Minify\Processor\HtmlCommentsRemover,
new gulch\Minify\Processor\InlineCssMinifier,
new gulch\Minify\Processor\InlineJavascriptMinifier,
new gulch\Minify\Processor\AttributesSimplifier,
new gulch\Minify\Processor\AttributeQuotesRemover,
);
$minified_code = $minifier->process($code);