Minify
Synopsis
A content optimization processor that minifies XML, JSON, and HTML documents by removing unnecessary whitespace, comments, and other non-essential elements to reduce file size and improve performance.
Schema
- minify:
field: <ident>
format: <enum>
target_field: <ident>
keep_whitespace: <boolean>
keep_comments: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
keep_end_tags: <boolean>
keep_document_tags: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Field containing the content to minify |
format | Y | - | Content format: xml, json, or html. Any other value fails the processor |
target_field | N | field | Field to store the minified content |
keep_whitespace | N | false | Preserve whitespace. XML and HTML only; JSON ignores it |
keep_comments | N | false | Preserve comments. HTML only — it also covers conditional comments. XML and JSON ignore it, and XML comments are always stripped |
keep_end_tags | N | false | Preserve end tags in HTML (HTML only) |
keep_document_tags | N | false | Preserve document tags in HTML (HTML only) |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue if minification fails |
ignore_missing | N | false | Continue if source field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
Details
The processor provides content minification for three primary formats: XML, JSON, and HTML. Each format has specific optimization strategies tailored to its structure and common use cases.
Minification is irreversible - ensure you preserve original content if needed.
XML minification removes whitespace between elements and always removes comments. keep_comments applies to HTML only. JSON compaction keeps number types, never writes a number in scientific notation, and takes no options. HTML is the only format that honours the full option set.
keep_end_tags, keep_document_tags and keep_comments reach the HTML minifier only. keep_whitespace reaches XML and HTML. Setting an option on a format that ignores it is silent, not an error.
Test minified content thoroughly as some applications may depend on specific formatting.
Examples
XML Minification
Minifying XML content... | |
produces compact XML: | |
JSON Minification
Compacting JSON data... | |
removes all formatting: | |
HTML Minification
Optimizing HTML content... | |
creates compact HTML: | |
Preserving Comments in HTML
| |
keeps the comment while removing the layout whitespace — the same configuration with | |
Conditional Minification
Minifying based on content size... | |
applies minification when needed: | |
HTML with Preserved Structure
Minifying HTML while keeping structure... | |
maintains essential HTML structure: | |