{"id":13437815,"url":"https://github.com/kangax/html-minifier","last_synced_at":"2025-09-09T20:46:06.979Z","repository":{"id":45317037,"uuid":"504220","full_name":"kangax/html-minifier","owner":"kangax","description":"Javascript-based HTML compressor/minifier (with Node.js support)","archived":false,"fork":false,"pushed_at":"2025-07-19T11:26:17.000Z","size":10789,"stargazers_count":5022,"open_issues_count":109,"forks_count":585,"subscribers_count":98,"default_branch":"gh-pages","last_synced_at":"2025-08-16T19:39:14.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://kangax.github.io/html-minifier/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kangax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-02-05T17:54:35.000Z","updated_at":"2025-08-15T12:48:53.000Z","dependencies_parsed_at":"2022-08-30T15:52:59.890Z","dependency_job_id":"473fd645-e1b7-4f0a-981b-cb6279b19a0a","html_url":"https://github.com/kangax/html-minifier","commit_stats":{"total_commits":1040,"total_committers":91,"mean_commits":"11.428571428571429","dds":0.6163461538461539,"last_synced_commit":"e15a892cd2f578aa281e766924fdd6f17f80f607"},"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"purl":"pkg:github/kangax/html-minifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kangax%2Fhtml-minifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kangax%2Fhtml-minifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kangax%2Fhtml-minifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kangax%2Fhtml-minifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kangax","download_url":"https://codeload.github.com/kangax/html-minifier/tar.gz/refs/heads/gh-pages","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kangax%2Fhtml-minifier/sbom","scorecard":{"id":549231,"data":{"date":"2025-08-11","repo":{"name":"github.com/kangax/html-minifier","commit":"a88e7ceabcb9817b36f31af648532b11ffca395e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Maintained","score":0,"reason":"1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":3,"reason":"Found 10/26 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:20","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:21","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/codeql.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/kangax/html-minifier/ci.yml/gh-pages?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/kangax/html-minifier/ci.yml/gh-pages?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/kangax/html-minifier/codeql.yml/gh-pages?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/kangax/html-minifier/codeql.yml/gh-pages?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/kangax/html-minifier/codeql.yml/gh-pages?enable=pin","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"27 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-wg6g-ppvx-927h","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-j383-35pm-c5h4","Warn: Project is vulnerable to: GHSA-rm36-94g8-835r","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T10:20:48.021Z","repository_id":45317037,"created_at":"2025-08-20T10:20:48.021Z","updated_at":"2025-08-20T10:20:48.021Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274359027,"owners_count":25270683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:00.422Z","updated_at":"2025-09-09T20:46:06.969Z","avatar_url":"https://github.com/kangax.png","language":"JavaScript","readme":"# Important\n\n## This version of html-minifier is no longer maintained. For an up-to-date version [which includes critical security fixes](https://meiert.com/blog/html-minifier-next/), please use [html-minifier-next](https://github.com/j9t/html-minifier-next) by @j9t.\n\n# HTMLMinifier\n\n[![npm version](https://img.shields.io/npm/v/html-minifier.svg)](https://www.npmjs.com/package/html-minifier)\n[![Build Status](https://img.shields.io/github/workflow/status/kangax/html-minifier/CI/gh-pages)](https://github.com/kangax/html-minifier/actions?query=workflow%3ACI+branch%3Agh-pages)\n[![Dependency Status](https://img.shields.io/david/kangax/html-minifier.svg)](https://david-dm.org/kangax/html-minifier)\n\n[HTMLMinifier](https://kangax.github.io/html-minifier/) is a highly **configurable**, **well-tested**, JavaScript-based HTML minifier.\n\nSee [corresponding blog post](http://perfectionkills.com/experimenting-with-html-minifier/) for all the gory details of [how it works](http://perfectionkills.com/experimenting-with-html-minifier/#how_it_works), [description of each option](http://perfectionkills.com/experimenting-with-html-minifier/#options), [testing results](http://perfectionkills.com/experimenting-with-html-minifier/#field_testing) and [conclusions](http://perfectionkills.com/experimenting-with-html-minifier/#cost_and_benefits).\n\n[Test suite is available online](https://kangax.github.io/html-minifier/tests/).\n\nAlso see corresponding [Ruby wrapper](https://github.com/stereobooster/html_minifier), and for Node.js, [Grunt plugin](https://github.com/gruntjs/grunt-contrib-htmlmin), [Gulp module](https://github.com/jonschlinkert/gulp-htmlmin), [Koa middleware wrapper](https://github.com/koajs/html-minifier) and [Express middleware wrapper](https://github.com/melonmanchan/express-minify-html).\n\nFor lint-like capabilities take a look at [HTMLLint](https://github.com/kangax/html-lint).\n\n## Minification comparison\n\nHow does HTMLMinifier compare to other solutions — [HTML Minifier from Will Peavy](http://www.willpeavy.com/minifier/) (1st result in [Google search for \"html minifier\"](https://www.google.com/#q=html+minifier)) as well as [htmlcompressor.com](http://htmlcompressor.com) and [minimize](https://github.com/Swaagie/minimize)?\n\n| Site                                                                         | Original size *(KB)* | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com |\n| ---------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|\n| [Google](https://www.google.com/)                                            | 46                   | **42**       | 46       | 48         | 46                 |\n| [HTMLMinifier](https://github.com/kangax/html-minifier)                      | 125                  | **98**       | 111      | 117        | 111                |\n| [Twitter](https://twitter.com/)                                              | 207                  | **165**      | 200      | 224        | 200                |\n| [Stack Overflow](https://stackoverflow.com/)                                 | 253                  | **195**      | 207      | 215        | 204                |\n| [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/)                      | 271                  | **260**      | 269      | 228        | 269                |\n| [BBC](https://www.bbc.co.uk/)                                                | 298                  | **239**      | 290      | 291        | 280                |\n| [Amazon](https://www.amazon.co.uk/)                                          | 422                  | **316**      | 412      | 425        | n/a                |\n| [NBC](https://www.nbc.com/)                                                  | 553                  | **530**      | 552      | 553        | 534                |\n| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States)    | 565                  | **461**      | 548      | 569        | 548                |\n| [New York Times](https://www.nytimes.com/)                                   | 678                  | **606**      | 675      | 670        | n/a                |\n| [Eloquent Javascript](https://eloquentjavascript.net/1st_edition/print.html) | 870                  | **815**      | 840      | 864        | n/a                |\n| [ES6 table](https://kangax.github.io/compat-table/es6/)                      | 5911                 | **5051**     | 5595     | n/a        | n/a                |\n| [ES draft](https://tc39.github.io/ecma262/)                                  | 6126                 | **5495**     | 5664     | n/a        | n/a                |\n\n## Options Quick Reference\n\nMost of the options are disabled by default.\n\n| Option                         | Description     | Default |\n|--------------------------------|-----------------|---------|\n| `caseSensitive`                | Treat attributes in case sensitive manner (useful for custom HTML tags) | `false` |\n| `collapseBooleanAttributes`    | [Omit attribute values from boolean attributes](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_boolean_attributes) | `false` |\n| `collapseInlineTagWhitespace`  | Don't leave any spaces between `display:inline;` elements when collapsing. Must be used in conjunction with `collapseWhitespace=true` | `false` |\n| `collapseWhitespace`           | [Collapse white space that contributes to text nodes in a document tree](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace) | `false` |\n| `conservativeCollapse`         | Always collapse to 1 space (never remove it entirely). Must be used in conjunction with `collapseWhitespace=true` | `false` |\n| `continueOnParseError`         | [Handle parse errors](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors) instead of aborting. | `false` |\n| `customAttrAssign`             | Arrays of regex'es that allow to support custom attribute assign expressions (e.g. `'\u003cdiv flex?=\"{{mode != cover}}\"\u003e\u003c/div\u003e'`) | `[ ]` |\n| `customAttrCollapse`           | Regex that specifies custom attribute to strip newlines from (e.g. `/ng-class/`) | |\n| `customAttrSurround`           | Arrays of regex'es that allow to support custom attribute surround expressions (e.g. `\u003cinput {{#if value}}checked=\"checked\"{{/if}}\u003e`) | `[ ]` |\n| `customEventAttributes`        | Arrays of regex'es that allow to support custom event attributes for `minifyJS` (e.g. `ng-click`) | `[ /^on[a-z]{3,}$/ ]` |\n| `decodeEntities`               | Use direct Unicode characters whenever possible | `false` |\n| `html5`                        | Parse input according to HTML5 specifications | `true` |\n| `ignoreCustomComments`         | Array of regex'es that allow to ignore certain comments, when matched | `[ /^!/ ]` |\n| `ignoreCustomFragments`        | Array of regex'es that allow to ignore certain fragments, when matched (e.g. `\u003c?php ... ?\u003e`, `{{ ... }}`, etc.)  | `[ /\u003c%[\\s\\S]*?%\u003e/, /\u003c\\?[\\s\\S]*?\\?\u003e/ ]` |\n| `includeAutoGeneratedTags`     | Insert tags generated by HTML parser | `true` |\n| `keepClosingSlash`             | Keep the trailing slash on singleton elements | `false` |\n| `maxLineLength`                | Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points |\n| `minifyCSS`                    | Minify CSS in style elements and style attributes (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)) | `false` (could be `true`, `Object`, `Function(text, type)`) |\n| `minifyJS`                     | Minify JavaScript in script elements and event attributes (uses [UglifyJS](https://github.com/mishoo/UglifyJS2)) | `false` (could be `true`, `Object`, `Function(text, inline)`) |\n| `minifyURLs`                   | Minify URLs in various attributes (uses [relateurl](https://github.com/stevenvachon/relateurl)) | `false` (could be `String`, `Object`, `Function(text)`) |\n| `preserveLineBreaks`           | Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with `collapseWhitespace=true` | `false` |\n| `preventAttributesEscaping`    | Prevents the escaping of the values of attributes | `false` |\n| `processConditionalComments`   | Process contents of conditional comments through minifier | `false` |\n| `processScripts`               | Array of strings corresponding to types of script elements to process through minifier (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.) | `[ ]` |\n| `quoteCharacter`               | Type of quote to use for attribute values (' or \") | |\n| `removeAttributeQuotes`        | [Remove quotes around attributes when possible](http://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes) | `false` |\n| `removeComments`               | [Strip HTML comments](http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments) | `false` |\n| `removeEmptyAttributes`        | [Remove all attributes with whitespace-only values](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_or_blank_attributes) | `false` (could be `true`, `Function(attrName, tag)`) |\n| `removeEmptyElements`          | [Remove all elements with empty contents](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements) | `false` |\n| `removeOptionalTags`           | [Remove optional tags](http://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags) | `false` |\n| `removeRedundantAttributes`    | [Remove attributes when value matches default.](http://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes) | `false` |\n| `removeScriptTypeAttributes`   | Remove `type=\"text/javascript\"` from `script` tags. Other `type` attribute values are left intact | `false` |\n| `removeStyleLinkTypeAttributes`| Remove `type=\"text/css\"` from `style` and `link` tags. Other `type` attribute values are left intact | `false` |\n| `removeTagWhitespace`          | Remove space between attributes whenever possible. **Note that this will result in invalid HTML!** | `false` |\n| `sortAttributes`               | [Sort attributes by frequency](#sorting-attributes--style-classes) | `false` |\n| `sortClassName`                | [Sort style classes by frequency](#sorting-attributes--style-classes) | `false` |\n| `trimCustomFragments`          | Trim white space around `ignoreCustomFragments`. | `false` |\n| `useShortDoctype`              | [Replaces the `doctype` with the short (HTML5) doctype](http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype) | `false` |\n\n### Sorting attributes / style classes\n\nMinifier options like `sortAttributes` and `sortClassName` won't impact the plain-text size of the output. However, they form long repetitive chains of characters that should improve compression ratio of gzip used in HTTP compression.\n\n## Special cases\n\n### Ignoring chunks of markup\n\nIf you have chunks of markup you would like preserved, you can wrap them `\u003c!-- htmlmin:ignore --\u003e`.\n\n### Preserving SVG tags\n\nSVG tags are automatically recognized, and when they are minified, both case-sensitivity and closing-slashes are preserved, regardless of the minification settings used for the rest of the file.\n\n### Working with invalid markup\n\nHTMLMinifier **can't work with invalid or partial chunks of markup**. This is because it parses markup into a tree structure, then modifies it (removing anything that was specified for removal, ignoring anything that was specified to be ignored, etc.), then it creates a markup out of that tree and returns it.\n\nInput markup (e.g. `\u003cp id=\"\"\u003efoo`)\n\n↓\n\nInternal representation of markup in a form of tree (e.g. `{ tag: \"p\", attr: \"id\", children: [\"foo\"] }`)\n\n↓\n\nTransformation of internal representation (e.g. removal of `id` attribute)\n\n↓\n\nOutput of resulting markup (e.g. `\u003cp\u003efoo\u003c/p\u003e`)\n\nHTMLMinifier can't know that original markup was only half of the tree; it does its best to try to parse it as a full tree and it loses information about tree being malformed or partial in the beginning. As a result, it can't create a partial/malformed tree at the time of the output.\n\n## Installation Instructions\n\nFrom NPM for use as a command line app:\n\n```shell\nnpm install html-minifier -g\n```\n\nFrom NPM for programmatic use:\n\n```shell\nnpm install html-minifier\n```\n\nFrom Git:\n\n```shell\ngit clone git://github.com/kangax/html-minifier.git\ncd html-minifier\nnpm link .\n```\n\n## Usage\n\nNote that almost all options are disabled by default. For command line usage please see `html-minifier --help` for a list of available options. Experiment and find what works best for you and your project.\n\n* **Sample command line:** ``html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true``\n\n### Node.js\n\n```js\nvar minify = require('html-minifier').minify;\nvar result = minify('\u003cp title=\"blah\" id=\"moo\"\u003efoo\u003c/p\u003e', {\n  removeAttributeQuotes: true\n});\nresult; // '\u003cp title=blah id=moo\u003efoo\u003c/p\u003e'\n```\n### Gulp\n\n```js\nconst { src, dest, series } = require('gulp');\nconst htmlMinify = require('html-minifier');\n\nconst options = {\n  includeAutoGeneratedTags: true,\n  removeAttributeQuotes: true,\n  removeComments: true,\n  removeRedundantAttributes: true,\n  removeScriptTypeAttributes: true,\n  removeStyleLinkTypeAttributes: true,\n  sortClassName: true,\n  useShortDoctype: true,\n  collapseWhitespace: true\n};\n\nfunction html() {\n  return src('app/**/*.html')\n    .on('data', function(file) {\n      const buferFile = Buffer.from(htmlMinify.minify(file.contents.toString(), options))\n      return file.contents = buferFile\n    })\n    .pipe(dest('build'))\n}\n\nexports.html = series(html)\n```\n\n## Running benchmarks\n\nBenchmarks for minified HTML:\n\n```shell\nnode benchmark.js\n```\n","funding_links":[],"categories":["JavaScript","Minifiers - HTML","\u003e 3k ★","Beautifier / Minifier"],"sub_categories":["Meetups"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkangax%2Fhtml-minifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkangax%2Fhtml-minifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkangax%2Fhtml-minifier/lists"}