{"id":46364487,"url":"https://github.com/jonasgeiler/astro-html-minifier-next","last_synced_at":"2026-03-05T02:02:59.080Z","repository":{"id":321818815,"uuid":"1076952979","full_name":"jonasgeiler/astro-html-minifier-next","owner":"jonasgeiler","description":"🔌 Minify Astro HTML assets using html-minifier-next!","archived":false,"fork":false,"pushed_at":"2026-02-28T21:33:21.000Z","size":223,"stargazers_count":1,"open_issues_count":9,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-01T00:44:24.392Z","etag":null,"topics":["astro","astro-integration","html-minifier","html-minifier-next","html-minifier-terser","minifier","optimization","withastro"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/astro-html-minifier-next","language":"TypeScript","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/jonasgeiler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"jonasgeiler","ko_fi":"jonasgeiler","liberapay":"jonasgeiler"}},"created_at":"2025-10-15T15:10:55.000Z","updated_at":"2026-02-23T21:50:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jonasgeiler/astro-html-minifier-next","commit_stats":null,"previous_names":["jonasgeiler/astro-html-minifier-next"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/jonasgeiler/astro-html-minifier-next","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasgeiler%2Fastro-html-minifier-next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasgeiler%2Fastro-html-minifier-next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasgeiler%2Fastro-html-minifier-next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasgeiler%2Fastro-html-minifier-next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonasgeiler","download_url":"https://codeload.github.com/jonasgeiler/astro-html-minifier-next/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasgeiler%2Fastro-html-minifier-next/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30106147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"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":["astro","astro-integration","html-minifier","html-minifier-next","html-minifier-terser","minifier","optimization","withastro"],"created_at":"2026-03-05T02:02:53.378Z","updated_at":"2026-03-05T02:02:59.069Z","avatar_url":"https://github.com/jonasgeiler.png","language":"TypeScript","funding_links":["https://github.com/sponsors/jonasgeiler","https://ko-fi.com/jonasgeiler","https://liberapay.com/jonasgeiler"],"categories":[],"sub_categories":[],"readme":"# astro-html-minifier-next\n\n\u003e Minify [Astro][astro] HTML assets using [html-minifier-next][html-minifier-next]!\n\n- **Improves page speed** - Reduces the size of HTML assets by removing everything unnecessary.\n- **Highly configurable** - All options from [html-minifier-next][html-minifier-next] are supported and can be customized.\n- **Fast** - Runs the minification of all assets with (limited) concurrency and [Lightning CSS][lightningcss].\n\n[![Version badge](https://img.shields.io/npm/v/astro-html-minifier-next?style=for-the-badge\u0026label=Version\u0026labelColor=2a2d35\u0026color=f2ebf4)][latest-release]\n[![NPM downloads badge](https://img.shields.io/npm/d18m/astro-html-minifier-next?style=for-the-badge\u0026label=NPM%20Downloads\u0026labelColor=2a2d35\u0026color=e13fa0\u0026cacheSeconds=86400)][package-on-npm]\n[![JSR score badge](https://jsr.io/badges/@jonasgeiler/astro-html-minifier-next/score?style=for-the-badge\u0026label=Score\u0026logoColor=fff\u0026labelColor=2a2d35\u0026color=f2ebf4\u0026cacheSeconds=86400)][package-on-jsr]\n[![NPM unpacked size badge](https://img.shields.io/npm/unpacked-size/astro-html-minifier-next?style=for-the-badge\u0026labelColor=2a2d35\u0026color=e13fa0)][package-on-bundlejs]\n\n```typescript\nimport { defineConfig } from \"astro/config\";\nimport htmlMinifier from \"astro-html-minifier-next\";\n\nexport default defineConfig({\n  integrations: [\n    htmlMinifier({\n      /* My recommended html-minifier-next options: */\n      caseSensitive: true,\n      collapseBooleanAttributes: true,\n      collapseInlineTagWhitespace: false,\n      collapseWhitespace: true,\n      conservativeCollapse: false,\n      continueOnMinifyError: false,\n      continueOnParseError: false,\n      decodeEntities: true,\n      html5: true,\n      includeAutoGeneratedTags: true,\n      keepClosingSlash: false,\n      minifyCSS: true,\n      minifyJS: true,\n      minifyURLs: false,\n      noNewlinesBeforeTagClose: false,\n      preserveLineBreaks: false,\n      preventAttributesEscaping: false,\n      processConditionalComments: false,\n      removeAttributeQuotes: false, // Technically they are optional and can greatly reduce size, but the HTML specification recommends always using quotes.\n      removeComments: true,\n      removeEmptyAttributes: true,\n      removeEmptyElements: false,\n      removeOptionalTags: false,\n      removeRedundantAttributes: true,\n      removeScriptTypeAttributes: true,\n      removeStyleLinkTypeAttributes: true,\n      removeTagWhitespace: false,\n      sortAttributes: false,\n      sortClassName: false,\n      useShortDoctype: true,\n    }),\n  ],\n});\n```\n\n## Installation\n\nAdd the integration to your Astro project using the `astro add` command.  \nThis will install the package and make the appropriate changes to your\n`astro.config.mjs`/`astro.config.ts` file in one step:\n```bash\nnpx astro add astro-html-minifier-next\n```\nIf you prefer to add the integration manually instead, complete the\nfollowing two steps:\n1. Install the package to your project’s dependencies using your preferred\n   package manager.  \n   If you’re using npm or aren’t sure, run this in the terminal:\n   ```bash\n   npm install --save-dev astro-html-minifier-next\n   ```\n   Or, if you're using Deno, run this in the terminal:\n   ```bash\n   deno add jsr:@jonasgeiler/astro-html-minifier-next\n   ```\n2. Add the integration to your `astro.config.mjs`/`astro.config.ts` file:\n   ```typescript\n   import { defineConfig } from \"astro/config\";\n   \n   // ADD THE FOLLOWING LINE:\n   import htmlMinifier from \"astro-html-minifier-next\";\n\n   export default defineConfig({\n     // ...\n   \n     integrations: [\n       // ...\n   \n       // ADD THE FOLLOWING LINE:\n       htmlMinifier({ /* Your html-minifier-next options here. */ }),\n     ],\n   });\n   ```\n\n## Usage\n\nOnce installed, the integration will automatically minify all HTML assets\ngenerated by Astro during the build process using the provided\n[html-minifier-next][html-minifier-next] options.\n\n### Options\n\nYou can find a quick reference of all available options in the\n[html-minifier-next documentation][html-minifier-next-options].  \nYou can also check out the\n[JSDoc comments in the source code][html-minifier-next-options-source].\n\nThere is currently one additional option only specific to this Astro\nintegration. [See below](#alwayswriteminifiedhtml).\n\n\u003e [!TIP]\n\u003e To ensure consistent and wide browser support throughout your project,\n\u003e I recommend setting the `targets` property of the `minifyCSS` option to your\n\u003e project's [Browserslist][browserslist] query.\n\u003e This configures [Lightning CSS][lightningcss] (the CSS minifier used by\n\u003e [html-minifier-next][html-minifier-next]) to properly optimize the CSS\n\u003e according to the browsers you want to support.\n\u003e \n\u003e You can do this, by adding the following lines to your\n\u003e `astro.config.mjs`/`astro.config.ts` file:\n\u003e ```typescript\n\u003e import { defineConfig } from \"astro/config\";\n\u003e import htmlMinifier from \"astro-html-minifier-next\";\n\u003e \n\u003e // ADD THE FOLLOWING LINES:\n\u003e import browserslist from \"browserslist\";\n\u003e import { browserslistToTargets } from \"lightningcss\";\n\u003e \n\u003e export default defineConfig({\n\u003e   // ...\n\u003e \n\u003e   integrations: [\n\u003e     // ...\n\u003e \n\u003e     htmlMinifier({\n\u003e       // ...\n\u003e \n\u003e       minifyCSS: {\n\u003e         // ...\n\u003e \n\u003e         // ADD THE FOLLOWING LINE:\n\u003e         targets: browserslistToTargets(browserslist(\"defaults\")),\n\u003e       },\n\u003e     }),\n\u003e   ],\n\u003e });\n\u003e ```\n\u003e \n\u003e More information can be found in the [Lightning CSS documentation][lightningcss-docs].\n\n#### `alwaysWriteMinifiedHTML`\n\nThis option is not passed to [html-minifier-next][html-minifier-next]. It\nonly controls the behavior of this Astro integration.\n\nBy default, the integration only overwrites the original HTML assets\nif the minified HTML is smaller.\nHowever, there are [cases][issue-7] where you might actually prefer the\nlarger output due to special compatibility reasons or otherwise.  \nSetting this option to `true` causes the integration to always overwrite\nthe HTML assets with their minified results, regardless of size.\n\n## Credits\n\nThis project wouldn't be possible without the awesome work of\n[Juriy Zaytsev aka. @kangax][@kangax] ([html-minifier][html-minifier]),\n[the Terser team][@terser] ([html-minifier-terser][html-minifier-terser]), and\nof course [Jens Oliver Meiert aka. @j9t][@j9t] ([html-minifier-next][html-minifier-next]).\n\n[astro]: https://astro.build/\n[html-minifier-next]: https://www.npmjs.com/package/html-minifier-next\n[html-minifier-next-options]: https://www.npmjs.com/package/html-minifier-next#options-quick-reference\n[html-minifier-next-options-source]: https://github.com/j9t/html-minifier-next/blob/e2995fc35a7a3906d3d1960d508d0d24a02128c8/src/htmlminifier.js#L1501\n[latest-release]: https://github.com/jonasgeiler/astro-html-minifier-next/releases/latest\n[package-on-bundlejs]: https://bundlejs.com/?q=astro-html-minifier-next\u0026config=%7B%22esbuild%22%3A%7B%22external%22%3A%5B%22lightningcss%22%5D%7D%7D\n[package-on-jsr]: https://jsr.io/@jonasgeiler/astro-html-minifier-next\n[package-on-npm]: https://www.npmjs.com/package/astro-html-minifier-next\n[browserslist]: https://browsersl.ist/\n[lightningcss]: https://lightningcss.dev/\n[lightningcss-docs]: https://lightningcss.dev/docs.html#with-vite\n[issue-7]: https://github.com/jonasgeiler/astro-html-minifier-next/issues/7\n[@kangax]: https://github.com/kangax\n[html-minifier]: https://github.com/kangax/html-minifier\n[@terser]: https://github.com/terser\n[html-minifier-terser]: https://github.com/terser/html-minifier-terser\n[@j9t]: https://github.com/j9t\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasgeiler%2Fastro-html-minifier-next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonasgeiler%2Fastro-html-minifier-next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasgeiler%2Fastro-html-minifier-next/lists"}