# hyperbuild A fast one-pass in-place HTML minifier written in Rust with advanced whitespace handling. Currently in beta, working on documentation and tests. Issues and pull requests welcome! Guide below is currently WIP. ## Features - Minification is done in one pass with no backtracking or DOM/AST building. - No dynamic memory is allocated during processing, which increases safety and performance. - Advanced whitespace handling options allow maximum minification while retaining valid spaces. ## Usage ```bash hyperbuild --src /path/to/src.html --out /path/to/output.min.html ``` ## Minification ### Whitespace hyperbuild has advanced whitespace minification that can allow strategies such as: - Leave whitespace untouched in `pre` and `code`, which are whitespace sensitive. - Trim and collapse whitespace in content tags, as whitespace is collapsed anyway when rendered. - Remove whitespace in layout tags, which allows the use of inline layouts while keeping formatted code. ### Attributes Any entities in attribute values are decoded, and then the most optimal representation is calculated and used: - Double quoted, with any `"` encoded. - Single quoted, with any `'` encoded. - Unquoted, with `"`/`'` first char (if applicable) and `>` last char (if applicable), and any whitespace, encoded. Some attributes have their whitespace (after decoding) trimmed and collapsed, such as `class`. If the attribute value is empty after any processing, it is completely removed (i.e. no `=`). Spaces are removed between attributes if possible. ### Other - Comments are removed. - Entities are decoded if valid (see relevant parsing section). ### WIP - Removal of [optional tags](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission). - Removal of boolean attribute values. - Removal of redundant attributes (empty or default value). - Handling of conditional or special comments. ### Explicitly important Empty elements and bangs are not removed as it is assumed there is a special reason for their declaration. ## Parsing hyperbuild is an HTML minifier and simply does HTML minification. In addition to keeping to one role, hyperbuild almost does no syntax checking or standards enforcement for performance and code complexity reasons. For example, this means that it's not an error to have self-closing tags, declare multiple `
` elements, use incorrect attribute names and values, or write something like `