http-strip-filter #
A dynamic nginx response-body minifier. Strips newlines, redundant whitespace and comments from HTML, CSS, JavaScript and JSON responses — context-aware, so significant bytes are never removed.
Source: our fork on GitHub
Directives
strip #
syntax: strip on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_css #
syntax: strip_css on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_js #
syntax: strip_js on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_json #
syntax: strip_json on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_max_size #
syntax: strip_max_size 1 arg (size (k/m/g)); · context: http, server, location
Set strip_max_size to skip very large responses (streaming, video manifests, etc.). - Inline <script>/<style> bodies in HTML are preserved verbatim; they are not recursively minified.
strip_min_size #
syntax: strip_min_size 1 arg (size (k/m/g)); · context: http, server, location
Size in bytes; accepts k / m / g suffixes.
strip_svg #
syntax: strip_svg on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_types #
syntax: strip_types 1+ args; · context: http, server, location
Adds MIME types, beyond text/html, that the HTML-stripping filter processes.
strip_xml #
syntax: strip_xml on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
Example
load_module modules/ngx_http_strip_filter_module.so;
http {
server {
strip on; # HTML
strip_css on;
strip_js on;
strip_json on;
}
}