middlewares/minifier

Middleware to minify Html, CSS and Javascript responses

v1.1.0 2018-08-04 10:41 UTC

README

Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

Middleware to minify the Html, CSS and Javascript content using mrclay/minify. This package is splited into the following components:

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/minifier.

composer require middlewares/minifier

Example

$dispatcher = new Dispatcher([
    new Middlewares\CssMinifier(),
    new Middlewares\JsMinifier(),
    new Middlewares\HtmlMinifier(),
]);

$response = $dispatcher->dispatch(new ServerRequest());

HtmlMinifier

Minifies the code of html responses. Make sure the response contains the header Content-Type: text/html (you can use middlewares/negotiation).

inlineCss($inlineCss = true)

Set false to do not minify inline css. (true by default)

inlineJs($inlineJs = true)

Set false to do not minify inline js. (true by default)

streamFactory(Psr\Http\Message\StreamFactoryInterface $streamFactory)

A PSR-17 factory to create the response body.

CssMinifier

Minifies the code of css responses. Make sure the response contains the header Content-Type: text/css.

streamFactory(Psr\Http\Message\StreamFactoryInterface $streamFactory)

A PSR-17 factory to create the response body.

JsMinifier

Minifies the code of javascript responses. Make sure the response contains the header Content-Type: text/javascript.

streamFactory(Psr\Http\Message\StreamFactoryInterface $streamFactory)

A PSR-17 factory to create the response body.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.