http-trim-filter #
Whitespace and comment stripper for HTML / JS / CSS response bodies — shrinks payloads on the fly without requiring a build-time minifier.
Source: our fork on GitHub
Directives
trim #
syntax: trim 1 arg; · context: http, server, location
Enables or disables HTML whitespace/comment trimming for the response via a complex-value expression evaluated per request.
trim_css #
syntax: trim_css 1 arg; · context: http, server, location
Enables or disables minification of inline CSS inside <style> blocks via a complex-value expression.
trim_js #
syntax: trim_js 1 arg; · context: http, server, location
Enables or disables minification of inline JavaScript inside <script> blocks via a complex-value expression.
trim_types #
syntax: trim_types 1+ args; · context: http, server, location
Adds MIME types, in addition to the default text/html, whose responses the trim filter processes.
Example
location / {
trim on;
trim_js on;
trim_css on;
trim_types text/html text/css application/javascript;
}