html-minifier
Version:
Highly effective, super-configurable, well-tested web page minifier
326 lines • 11.3 kB
JSON
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/j9t/html-minifier/main/html-minifier.schema.json",
"title": "HTML Minifier configuration",
"description": "Configuration file for HTML Minifier (HM), used via `--config-file`",
"type": "object",
"properties": {
"$schema": {
"description": "JSON Schema reference for this configuration file (enables editor validation and autocomplete)",
"type": "string"
},
"preset": {
"description": "Preset configuration to start from—config file options override preset options",
"enum": [
"conservative",
"comprehensive"
]
},
"fileExt": {
"description": "File extension(s) to process, as comma-separated string or array (default: `html,htm,shtml,shtm`; use `*` for all files)",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"ignoreDir": {
"description": "Directories—relative to the input directory—to exclude from processing, as comma-separated string or array",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"cacheCSS": {
"description": "Set CSS minification cache size (number of entries, default: 500)",
"type": "integer",
"minimum": 0
},
"cacheJS": {
"description": "Set JavaScript minification cache size (number of entries, default: 500)",
"type": "integer",
"minimum": 0
},
"cacheSVG": {
"description": "Set SVG minification cache size (number of entries, default: 500)",
"type": "integer",
"minimum": 0
},
"caseSensitive": {
"description": "Keep element and attribute names as written (e.g., for framework components like `<MyButton>`)",
"type": "boolean"
},
"collapseAttributeWhitespace": {
"description": "Trim and collapse whitespace characters within attribute values",
"type": "boolean"
},
"collapseBooleanAttributes": {
"description": "Omit attribute values from boolean attributes",
"type": "boolean"
},
"collapseEmptyAttributes": {
"description": "Omit empty attribute values (e.g., `alt=\"\"` → `alt`)",
"type": "boolean"
},
"collapseInlineTagWhitespace": {
"description": "Collapse whitespace more aggressively between inline elements—use with `--collapse-whitespace`",
"type": "boolean"
},
"collapseNoBreakSpaces": {
"description": "Remove whitespace next to no-break spaces, narrow no-break spaces, and figure spaces in text (e.g., `a b` → `a b`), keeping runs of them—use with `--collapse-whitespace`",
"type": "boolean"
},
"collapseWhitespace": {
"description": "Collapse whitespace that contributes to text nodes in a document tree",
"type": "boolean"
},
"conservativeCollapse": {
"description": "Always collapse to one space (never remove it entirely)—use with `--collapse-whitespace`",
"type": "boolean"
},
"continueOnMinifyError": {
"description": "Continue on minification errors",
"type": "boolean"
},
"continueOnParseError": {
"description": "Handle parse errors instead of aborting",
"type": "boolean"
},
"customAttrAssign": {
"description": "Array of regexes that allow to support custom attribute assign expressions (e.g., `<div flex?=\"{{mode != cover}}\"></div>`)",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"customAttrCollapse": {
"description": "Regex that specifies custom attribute to strip newlines from (e.g., `/ng-class/`)",
"type": "string"
},
"customAttrSurround": {
"description": "Array of regexes that allow to support custom attribute surround expressions (e.g., `<input {{#if value}}checked=\"checked\"{{/if}}>`)",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"customEventAttributes": {
"description": "Array of regexes that allow to support custom event attributes (e.g., `ng-click`)—use with `--minify-js`",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"decodeEntities": {
"description": "Use direct Unicode characters whenever possible",
"type": "boolean"
},
"ignoreCustomComments": {
"description": "Array of regexes that allow to ignore matching comments",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"ignoreCustomFragments": {
"description": "Array of regexes that allow to ignore certain fragments, when matched (e.g., `<?php … ?>`, `{{ … }}`, etc.)",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"includeAutoGeneratedTags": {
"description": "Insert elements generated by HTML parser",
"type": "boolean"
},
"inlineCustomElements": {
"description": "Array of names of custom elements which are inline, for whitespace handling—use with `--collapse-whitespace`",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"keepClosingSlash": {
"description": "Keep the trailing slash on void elements and other start tags that carry one, and read it as closing the element",
"type": "boolean"
},
"maxInputLength": {
"description": "Maximum input length to prevent ReDoS attacks",
"type": "integer",
"minimum": 0
},
"maxLineLength": {
"description": "Specify a maximum line length; output will be split by newlines in tags only (between attributes or before a tag’s `>`), where they can’t change the page, so lines may run longer",
"type": "integer",
"minimum": 0
},
"mergeScripts": {
"description": "Merge consecutive `script` elements into one",
"type": "boolean"
},
"mergeStyles": {
"description": "Merge consecutive `style` elements into one",
"type": "boolean"
},
"minifyCSS": {
"description": "Minify CSS in `style` elements and attributes (uses Lightning CSS)",
"type": [
"boolean",
"object"
]
},
"minifyJS": {
"description": "Minify JavaScript in `script` elements and event attributes (uses Terser or SWC; pass `{\"engine\": \"swc\"}` for SWC)",
"type": [
"boolean",
"object"
]
},
"minifyJSON": {
"description": "Minify JSON in `script` elements (e.g., `application/ld+json`, `importmap`, etc.) by removing whitespace",
"type": "boolean"
},
"minifySVG": {
"description": "Minify SVG elements (uses SVGO)",
"type": [
"boolean",
"object"
]
},
"minifyURLs": {
"description": "Minify URLs in various attributes",
"type": [
"boolean",
"string",
"object"
]
},
"noNewlinesBeforeTagClose": {
"description": "Never split a line in a tag that closes an element—use with `--max-line-length`",
"type": "boolean"
},
"partialMarkup": {
"description": "Treat input as a partial HTML fragment, preserving stray end tags and unclosed tags",
"type": "boolean"
},
"preserveLineBreaks": {
"description": "Always collapse to one line break (never remove it entirely) when whitespace between tags includes a line break—use with `--collapse-whitespace`",
"type": "boolean"
},
"preventAttributesEscaping": {
"description": "Prevents the escaping of the values of attributes",
"type": "boolean"
},
"processScripts": {
"description": "Array of strings corresponding to types of `script` elements to process through minifier (e.g., `text/ng-template`, `text/x-handlebars-template`, etc.)",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"quoteCharacter": {
"description": "Type of quote to use for attribute values (`'` or `\"`)",
"type": "string"
},
"removeAttributeQuotes": {
"description": "Remove quotes around attributes when possible",
"type": "boolean"
},
"removeComments": {
"description": "Strip HTML comments",
"type": "boolean"
},
"removeDefaultTypeAttributes": {
"description": "Remove default `type` attributes from `style`/`link` (e.g., `type=\"text/css\"`) and `script` (e.g., `type=\"text/javascript\"`) elements; other `type` attribute values are left intact",
"type": "boolean"
},
"removeEmptyAttributes": {
"description": "Remove all attributes with whitespace-only values",
"type": "boolean"
},
"removeEmptyElements": {
"description": "Remove all elements with empty contents",
"type": "boolean"
},
"removeEmptyElementsExcept": {
"description": "Array of elements to preserve (e.g., `td`, `<i class=\"test\">`, etc.)—use with `--remove-empty-elements`",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"removeOptionalTags": {
"description": "Remove optional tags",
"type": "boolean"
},
"removeRedundantAttributes": {
"description": "Remove attributes when value matches default or has no effect (as well as `rel` keywords and `meta` elements without effect)",
"type": "boolean"
},
"removeTagWhitespace": {
"description": "Remove space between attributes whenever possible; note that this will result in invalid HTML",
"type": "boolean"
},
"removeUnusedCSS": {
"description": "Remove CSS from `style` elements that name an element, class, or ID the document doesn’t reference—use with `--minify-css`, and `{\"safelist\": […]}` for names only external scripts use",
"type": [
"boolean",
"object"
]
},
"selfCloseForeignElements": {
"description": "Self-close empty SVG and MathML elements (e.g., `<path d=\"…\"></path>` → `<path d=\"…\"/>`)",
"type": "boolean"
},
"sortAttributes": {
"description": "Sort attributes by frequency",
"type": "boolean"
},
"sortClassNames": {
"description": "Sort style classes by frequency",
"type": "boolean"
},
"trimCustomFragments": {
"description": "Trim whitespace around custom fragments (`--ignore-custom-fragments`) where it doesn’t affect the output—use with `--collapse-whitespace`",
"type": "boolean"
},
"strictCustomFragments": {
"description": "Reject `ignoreCustomFragments` patterns that risk catastrophic backtracking (rather than warning about them)",
"type": "boolean"
},
"useShortDoctype": {
"description": "Convert any doctype to the short HTML doctype (switches pages with legacy doctypes to standards mode)",
"type": "boolean"
}
},
"additionalProperties": false
}