Skip to content

Latest commit

 

History

History
52 lines (31 loc) · 1.8 KB

README.md

File metadata and controls

52 lines (31 loc) · 1.8 KB

http-message-strategies-interop/example-minifier

A middlewares/minifier fork, but using HTTP Message Strategies PSR (pre-Draft)

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

Example

$streamFactory = new StreamFactory(); // A PSR-17 StreamFactory

foreach ([
    new CssMinifier($streamFactory),
    new JsMinifier($streamFactory),
    new HtmlMinifier($streamFactory),
] as $minifier) {
    $response = $minifier($response);
}

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)

CssMinifier

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

JsMinifier

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

Related

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