Skip to content

HTTP Message Strategies Example to minify Html, CSS and Javascript responses

License

Notifications You must be signed in to change notification settings

http-message-strategies-interop/example-minifier

 
 

Repository files navigation

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.

About

HTTP Message Strategies Example to minify Html, CSS and Javascript responses

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 78.5%
  • HTML 16.8%
  • JavaScript 2.8%
  • CSS 1.9%