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 |
target_field | N | field | Field to store the minified content |
keep_whitespace | N | false | Preserve whitespace in content |
keep_comments | N | false | Preserve comments in content |
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 |
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 unnecessary whitespace between elements while preserving content integrity. JSON minification eliminates all non-essential whitespace and formatting. HTML minification offers comprehensive optimization including whitespace removal, comment deletion, and optional tag optimization.
Format-specific options provide fine-grained control over minification behavior. HTML-specific options like keep_end_tags
and keep_document_tags
allow preservation of structural elements when required.
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
Minifying while keeping comments... |
|
preserves important comments: |
|
Conditional Minification
Minifying based on content size... |
|
applies minification when needed: |
|
HTML with Preserved Structure
Minifying HTML while keeping structure... |
|
maintains essential HTML structure: |
|