{"id":50801771,"url":"https://github.com/jaywcjlove/HTMLMinifier","last_synced_at":"2026-06-30T03:00:37.021Z","repository":{"id":310864123,"uuid":"1041541889","full_name":"jaywcjlove/HTMLMinifier","owner":"jaywcjlove","description":"A Swift HTML minification library based on JavaScriptCore and html-minifier-next.","archived":false,"fork":false,"pushed_at":"2026-03-17T04:16:39.000Z","size":433,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-05T12:04:19.582Z","etag":null,"topics":["html","html-minifier","htmlminify","minifier","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/jaywcjlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["jaywcjlove"]}},"created_at":"2025-08-20T16:33:08.000Z","updated_at":"2026-03-17T04:16:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"3920a684-4423-4a3e-8fa1-cabe4e92ff33","html_url":"https://github.com/jaywcjlove/HTMLMinifier","commit_stats":null,"previous_names":["jaywcjlove/htmlminifier"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jaywcjlove/HTMLMinifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2FHTMLMinifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2FHTMLMinifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2FHTMLMinifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2FHTMLMinifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaywcjlove","download_url":"https://codeload.github.com/jaywcjlove/HTMLMinifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2FHTMLMinifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34950330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"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":["html","html-minifier","htmlminify","minifier","swift","swift-package-manager"],"created_at":"2026-06-12T21:00:28.531Z","updated_at":"2026-06-30T03:00:37.008Z","avatar_url":"https://github.com/jaywcjlove.png","language":"Swift","funding_links":["https://github.com/sponsors/jaywcjlove"],"categories":["Developer Tools"],"sub_categories":[],"readme":"\u003cdiv markdown=\"1\"\u003e\n  \u003csup\u003eUsing \u003ca href=\"https://wangchujiang.com/#/app\" target=\"_blank\"\u003emy app\u003c/a\u003e is also a way to \u003ca href=\"https://wangchujiang.com/#/sponsor\" target=\"_blank\"\u003esupport\u003c/a\u003e me:\u003c/sup\u003e\n  \u003cbr\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6758053530\" title=\"Scap: Screenshot \u0026 Markup Edit for macOS\"\u003e\u003cimg alt=\"Scap: Screenshot \u0026 Markup Edit\" height=\"52\" src=\"https://wangchujiang.com/appicon/scap.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6757317079\" title=\"Screen Test for macOS\"\u003e\u003cimg alt=\"Screen Test\" height=\"52\" src=\"https://wangchujiang.com/appicon/screen-test.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6755948110\" title=\"Deskmark for macOS\"\u003e\u003cimg alt=\"Deskmark\" height=\"52\" src=\"https://wangchujiang.com/appicon/deskmark.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6500434773\" title=\"Keyzer for macOS\"\u003e\u003cimg alt=\"Keyzer\" height=\"52\" src=\"https://wangchujiang.com/appicon/keyzer.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://github.com/jaywcjlove/vidwall-hub\" title=\"Vidwall Hub for macOS\"\u003e\u003cimg alt=\"Vidwall Hub\" height=\"52\" src=\"https://wangchujiang.com/appicon/vidwall-hub.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6752624705\" title=\"VidCrop for macOS\"\u003e\u003cimg alt=\"VidCrop\" height=\"52\" src=\"https://wangchujiang.com/appicon/vidcrop.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6747587746\" title=\"Vidwall for macOS\"\u003e\u003cimg alt=\"Vidwall\" height=\"52\" src=\"https://wangchujiang.com/appicon/vidwall.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://wangchujiang.com/mousio-hint/\" title=\"Mousio Hint for macOS\"\u003e\u003cimg alt=\"Mousio Hint\" height=\"52\" src=\"https://wangchujiang.com/appicon/mousio-hint.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6746747327\" title=\"Mousio for macOS\"\u003e\u003cimg alt=\"Mousio\" height=\"52\" src=\"https://wangchujiang.com/appicon/mousio.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6745227444\" title=\"Musicer for macOS\"\u003e\u003cimg alt=\"Musicer\" height=\"52\" src=\"https://wangchujiang.com/appicon/musicer.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6743841447\" title=\"Audioer for macOS\"\u003e\u003cimg alt=\"Audioer\" height=\"52\" src=\"https://wangchujiang.com/appicon/audioer.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6744690194\" title=\"FileSentinel for macOS\"\u003e\u003cimg alt=\"FileSentinel\" height=\"52\" src=\"https://wangchujiang.com/appicon/file-sentinel.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6743495172\" title=\"FocusCursor for macOS\"\u003e\u003cimg alt=\"FocusCursor\" height=\"52\" src=\"https://wangchujiang.com/appicon/focus-cursor.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6742680573\" title=\"Videoer for macOS\"\u003e\u003cimg alt=\"Videoer\" height=\"52\" src=\"https://wangchujiang.com/appicon/videoer.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6740425504\" title=\"KeyClicker for macOS\"\u003e\u003cimg alt=\"KeyClicker\" height=\"52\" src=\"https://wangchujiang.com/appicon/key-clicker.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6739052447\" title=\"DayBar for macOS\"\u003e\u003cimg alt=\"DayBar\" height=\"52\" src=\"https://wangchujiang.com/appicon/daybar.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6739444407\" title=\"Iconed for macOS\"\u003e\u003cimg alt=\"Iconed\" height=\"52\" src=\"https://wangchujiang.com/appicon/iconed.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6737160756\" title=\"Menuist for macOS\"\u003e\u003cimg alt=\"Menuist\" height=\"52\" src=\"https://wangchujiang.com/appicon/rightmenu-master.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6723903021\" title=\"Paste Quick for macOS\"\u003e\u003cimg alt=\"Quick RSS\" height=\"52\" src=\"https://wangchujiang.com/appicon/paste-quick.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6670696072\u0026platform=mac\" title=\"Quick RSS for macOS/iOS\"\u003e\u003cimg alt=\"Quick RSS\" height=\"52\" src=\"https://wangchujiang.com/appicon/quick-rss.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6670167443\" title=\"Web Serve for macOS\"\u003e\u003cimg alt=\"Web Serve\" height=\"52\" src=\"https://wangchujiang.com/appicon/web-serve.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6503953628\u0026platform=mac\" title=\"Copybook Generator for macOS/iOS\"\u003e\u003cimg alt=\"Copybook Generator\" height=\"52\" src=\"https://wangchujiang.com/appicon/copybook-generator.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6471227008\u0026platform=mac\" title=\"DevTutor for macOS/iOS\"\u003e\u003cimg alt=\"DevTutor for SwiftUI\" height=\"52\" src=\"https://wangchujiang.com/appicon/devtutor.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6479819388\u0026platform=mac\" title=\"RegexMate for macOS/iOS\"\u003e\u003cimg alt=\"RegexMate\" height=\"52\" src=\"https://wangchujiang.com/appicon/regex-mate.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6479194014\u0026platform=mac\" title=\"Time Passage for macOS/iOS\"\u003e\u003cimg alt=\"Time Passage\" height=\"52\" src=\"https://wangchujiang.com/appicon/time-passage.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6478772538\" title=\"IconizeFolder for macOS\"\u003e\u003cimg alt=\"Iconize Folder\" height=\"52\" src=\"https://wangchujiang.com/appicon/iconize-folder.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6478511402\u0026platform=mac\" title=\"Textsound Saver for macOS/iOS\"\u003e\u003cimg alt=\"Textsound Saver\" height=\"52\" src=\"https://wangchujiang.com/appicon/textsound-saver.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6476924627\" title=\"Create Custom Symbols for macOS\"\u003e\u003cimg alt=\"Create Custom Symbols\" height=\"52\" src=\"https://wangchujiang.com/appicon/create-custom-symbols.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6476452351\" title=\"DevHub for macOS\"\u003e\u003cimg alt=\"DevHub\" height=\"52\" src=\"https://wangchujiang.com/appicon/devhub.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6476400184\" title=\"Resume Revise for macOS\"\u003e\u003cimg alt=\"Resume Revise\" height=\"52\" src=\"https://wangchujiang.com/appicon/resume-revise.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6472593276\" title=\"Palette Genius for macOS\"\u003e\u003cimg alt=\"Palette Genius\" height=\"52\" src=\"https://wangchujiang.com/appicon/palette-genius.png\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6470879005\" title=\"Symbol Scribe for macOS\"\u003e\u003cimg alt=\"Symbol Scribe\" height=\"52\" src=\"https://wangchujiang.com/appicon/symbol-scribe.png\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003chr\u003e\n\nHTMLMinifier\n===\n\n[![Buy me a coffee](https://img.shields.io/badge/Buy_Me_a_Coffee-ffdd00?logo=buy-me-a-coffee\u0026logoColor=black)](https://jaywcjlove.github.io/#/sponsor)\n[![Follow On X](https://img.shields.io/badge/Follow%20on%20X-333333?logo=x\u0026logoColor=white)](https://x.com/jaywcjlove)\n\nA Swift HTML minification library based on JavaScriptCore and [html-minifier-next](https://www.npmjs.com/html-minifier-next).\n\n## Installation\n\n### Swift Package Manager\n\nAdd CodeMirror to your project using Xcode:\n\n1. In Xcode, go to `File` → `Add Package Dependencies...`\n2. Enter the repository URL: `https://github.com/jaywcjlove/HTMLMinifier.git`\n3. Click `Add Package`\n\nOr add it to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/jaywcjlove/HTMLMinifier.git\", from: \"1.0.0\")\n]\n```\n\n## Usage\n\n### Basic Usage\n\n```swift\nimport HTMLMinifier\n\nlet html = \"\"\"\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eTest\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cp class=\"test\"\u003e  Hello World  \u003c/p\u003e\n    \u003c!-- This is a comment --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\"\"\"\n\n// Using default options\nlet minified = try HTMLMinifier.minify(html)\nprint(minified)\n```\n\n### Custom Options\n\n```swift\nimport HTMLMinifier\n\nlet options = HTMLMinifierOptions(\n    removeComments: true,\n    collapseWhitespace: true,\n    removeAttributeQuotes: true,\n    useShortDoctype: true\n)\n\nlet minifier = try HTMLMinifier()\nlet result = try minifier.minify(html, options: options)\n```\n\n### Static Methods\n\n```swift\n// Using default options\nlet result1 = try HTMLMinifier.minify(html)\n\n// Using custom options\nlet result2 = try HTMLMinifier.minify(html, options: options)\n```\n\n## Available Options\n\nAll options are disabled by default unless specified otherwise.\n\n### Core Options\n\n- `caseSensitive` (default: `false`): Treat attributes in case sensitive manner (useful for custom HTML tags)\n- `html5` (default: `true`): Parse input according to HTML5 specifications\n- `includeAutoGeneratedTags` (default: `true`): Insert tags generated by HTML parser\n- `continueOnParseError` (default: `false`): Handle parse errors instead of aborting\n\n### Whitespace \u0026 Formatting\n\n- `collapseWhitespace` (default: `false`): Collapse white space that contributes to text nodes in a document tree\n- `collapseInlineTagWhitespace` (default: `false`): Don't leave any spaces between `display:inline;` elements when collapsing (must be used with `collapseWhitespace=true`)\n- `conservativeCollapse` (default: `false`): Always collapse to 1 space (never remove it entirely). Must be used with `collapseWhitespace=true`\n- `preserveLineBreaks` (default: `false`): Always collapse to 1 line break when whitespace between tags include a line break. Must be used with `collapseWhitespace=true`\n- `trimCustomFragments` (default: `false`): Trim white space around `ignoreCustomFragments`\n- `noNewlinesBeforeTagClose` (default: `false`): Never add a newline before a tag that closes an element\n\n### Attributes\n\n- `removeAttributeQuotes` (default: `false`): Remove quotes around attributes when possible\n- `collapseBooleanAttributes` (default: `false`): Omit attribute values from boolean attributes\n- `removeEmptyAttributes` (default: `false`): Remove all attributes with whitespace-only values\n- `removeRedundantAttributes` (default: `false`): Remove attributes when value matches default\n- `preventAttributesEscaping` (default: `false`): Prevents the escaping of the values of attributes\n- `removeTagWhitespace` (default: `false`): Remove space between attributes whenever possible (**Note: this will result in invalid HTML!**)\n- `sortAttributes` (default: `false`): Sort attributes by frequency\n\n### Comments \u0026 Elements\n\n- `removeComments` (default: `false`): Strip HTML comments\n- `processConditionalComments` (default: `false`): Process contents of conditional comments through minifier\n- `removeEmptyElements` (default: `false`): Remove all elements with empty contents\n- `removeOptionalTags` (default: `false`): Remove optional tags\n\n### Type Attributes\n\n- `removeScriptTypeAttributes` (default: `false`): Remove `type=\"text/javascript\"` from `script` tags. Other `type` attribute values are left intact\n- `removeStyleLinkTypeAttributes` (default: `false`): Remove `type=\"text/css\"` from `style` and `link` tags. Other `type` attribute values are left intact\n\n### Content Minification\n\n- `minifyJS` (default: `false`): Minify JavaScript in script elements and event attributes\n- `minifyCSS` (default: `false`): Minify CSS in style elements and style attributes\n- `minifyURLs` (default: `false`): Minify URLs in various attributes\n\n### Document Structure\n\n- `useShortDoctype` (default: `false`): Replaces the `doctype` with the short (HTML5) doctype\n- `keepClosingSlash` (default: `false`): Keep the trailing slash on singleton elements\n- `decodeEntities` (default: `false`): Use direct Unicode characters whenever possible\n- `sortClassName` (default: `false`): Sort style classes by frequency\n\n### Advanced Options\n\n- `quoteCharacter` (default: `nil`): Type of quote to use for attribute values (\"'\" or \"\"\")\n- `maxInputLength` (default: `nil`): Maximum input length to prevent ReDoS attacks\n- `maxLineLength` (default: `nil`): Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points\n\n### Example with Common Options\n\n```swift\nlet options = HTMLMinifierOptions(\n    removeComments: true,\n    collapseWhitespace: true,\n    removeAttributeQuotes: true,\n    collapseBooleanAttributes: true,\n    removeEmptyAttributes: true,\n    removeRedundantAttributes: true,\n    removeScriptTypeAttributes: true,\n    removeStyleLinkTypeAttributes: true,\n    useShortDoctype: true,\n    minifyJS: true,\n    minifyCSS: true\n)\n```\n\n## Error Handling\n\n```swift\ndo {\n    let result = try HTMLMinifier.minify(html)\n    print(result)\n} catch HTMLMinifierError.jsContextCreationFailed {\n    print(\"Failed to create JavaScript context\")\n} catch HTMLMinifierError.jsScriptLoadFailed(let message) {\n    print(\"JavaScript script loading failed: \\(message)\")\n} catch HTMLMinifierError.minificationFailed(let message) {\n    print(\"Minification failed: \\(message)\")\n} catch HTMLMinifierError.invalidInput {\n    print(\"Invalid input\")\n}\n```\n\n## License\n\nLicensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaywcjlove%2FHTMLMinifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaywcjlove%2FHTMLMinifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaywcjlove%2FHTMLMinifier/lists"}