{"id":31544725,"url":"https://github.com/jaywcjlove/htmlminifier","last_synced_at":"2025-10-28T21:12:37.492Z","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":"2025-09-18T14:44:25.000Z","size":422,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-01T06:36:43.126Z","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":{"ko_fi":"jaywcjlove","buy_me_a_coffee":"jaywcjlove","custom":["https://www.paypal.me/kennyiseeyou","https://jaywcjlove.github.io/#/sponsor"]}},"created_at":"2025-08-20T16:33:08.000Z","updated_at":"2025-09-18T14:44:29.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":278322182,"owners_count":25967873,"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-10-04T02:00:05.491Z","response_time":63,"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":"2025-10-04T13:50:15.234Z","updated_at":"2025-10-04T13:50:17.015Z","avatar_url":"https://github.com/jaywcjlove.png","language":"Swift","funding_links":["https://ko-fi.com/jaywcjlove","https://buymeacoffee.com/jaywcjlove","https://www.paypal.me/kennyiseeyou","https://jaywcjlove.github.io/#/sponsor"],"categories":[],"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://apps.apple.com/app/VidCrop/6752624705\" title=\"VidCrop for macOS\"\u003e\u003cimg align=\"center\" alt=\"VidCrop\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/91d2b281-271a-4107-9ef6-f3b11bd6dbac\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/Vidwall/6747587746\" title=\"Vidwall for macOS\"\u003e\u003cimg align=\"center\" alt=\"Vidwall\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/7b5df70a-ed91-4d4b-85be-f00e60a09ce9\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://wangchujiang.com/mousio-hint/\" title=\"Mousio Hint for macOS\"\u003e\u003cimg align=\"center\" alt=\"Mousio Hint\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/3c0af128-0cef-44e5-a8db-4741dc5a6690\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6746747327\" title=\"Mousio for macOS\"\u003e\u003cimg align=\"center\" alt=\"Mousio\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/9edf61ff-5a6c-4676-9cc2-8fd3c1ad0dfb\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6745227444\" title=\"Musicer for macOS\"\u003e\u003cimg align=\"center\" alt=\"Musicer\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/b7abfba8-88ff-4c86-a125-43073d5aef22\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6743841447\" title=\"Audioer for macOS\"\u003e\u003cimg align=\"center\" alt=\"Audioer\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/7a836865-8c90-4119-87bc-19e06a76c957\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6744690194\" title=\"FileSentinel for macOS\"\u003e\u003cimg align=\"center\" alt=\"FileSentinel\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/28bce2cc-290e-45bf-9068-585ff6ecafe9\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6743495172\" title=\"FocusCursor for macOS\"\u003e\u003cimg align=\"center\" alt=\"FocusCursor\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/d543668a-737b-4853-a6bb-eaa269e69836\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6742680573\" title=\"Videoer for macOS\"\u003e\u003cimg align=\"center\" alt=\"Videoer\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/10ffb0f1-0625-40d6-93f1-2c2496592595\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6740425504\" title=\"KeyClicker for macOS\"\u003e\u003cimg align=\"center\" alt=\"KeyClicker\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/5a19fcb9-cb81-4855-b4ea-31c604d9612a\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6739052447\" title=\"DayBar for macOS\"\u003e\u003cimg align=\"center\" alt=\"DayBar\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/771b608d-594c-492d-8532-d9231e383f5b\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6739444407\" title=\"Iconed for macOS\"\u003e\u003cimg align=\"center\" alt=\"Iconed\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/8a35dc7b-4faf-4e2a-9311-f66d6844a896\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6737160756\" title=\"RightMenu Master for macOS\"\u003e\u003cimg align=\"center\" alt=\"RightMenu Master\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/39a76541-71bf-4de7-a01c-c62f0557dff5\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6723903021\" title=\"Paste Quick for macOS\"\u003e\u003cimg align=\"center\" alt=\"Quick RSS\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/bdaad5b7-9810-44ce-8f17-8410864465d2\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6670696072\" title=\"Quick RSS for macOS/iOS\"\u003e\u003cimg align=\"center\" alt=\"Quick RSS\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/374106b5-a448-4d1d-9ccb-b04b6bc681ed\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6670167443\" title=\"Web Serve for macOS\"\u003e\u003cimg align=\"center\" alt=\"Web Serve\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/e1d9f76f-0f3d-4ba5-8a15-253ee173bb1c\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6503953628\" title=\"Copybook Generator for macOS/iOS\"\u003e\u003cimg align=\"center\" alt=\"Copybook Generator\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/b90e42ff-158b-4534-82ca-5898fd0e8d73\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6471227008\" title=\"DevTutor for macOS/iOS\"\u003e\u003cimg align=\"center\" alt=\"DevTutor for SwiftUI\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/f15c154d-0192-48eb-8e0e-9e245ffd974a\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6479819388\" title=\"RegexMate for macOS/iOS\"\u003e\u003cimg align=\"center\" alt=\"RegexMate\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/aabe5aa9-9a96-4390-8bed-c3e4023d0dea\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6479194014\" title=\"Time Passage for macOS/iOS\"\u003e\u003cimg align=\"center\" alt=\"Time Passage\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/time-passage/assets/1680273/6f30e429-e6f3-4dbe-9921-a5effe2a05e9\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6478772538\" title=\"IconizeFolder for macOS\"\u003e\u003cimg align=\"center\" alt=\"Iconize Folder\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/fa9d8b9c-1e51-4ded-877c-fa5b21c47220\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6478511402\" title=\"Textsound Saver for macOS/iOS\"\u003e\u003cimg align=\"center\" alt=\"Textsound Saver\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/0595e842-980b-4574-8891-a8ba853a08be\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6476924627\" title=\"Create Custom Symbols for macOS\"\u003e\u003cimg align=\"center\" alt=\"Create Custom Symbols\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/8cd022ce-a3f1-4e89-b7c6-6fbd0d4db77c\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6476452351\" title=\"DevHub for macOS\"\u003e\u003cimg align=\"center\" alt=\"DevHub\" height=\"52\" width=\"52\" src=\"https://github.com/user-attachments/assets/4a44a4fd-67ce-430b-af0a-72f18feaa47d\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6476400184\" title=\"Resume Revise for macOS\"\u003e\u003cimg align=\"center\" alt=\"Resume Revise\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/c9954a20-1905-48de-bdf8-d71837974aa2\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6472593276\" title=\"Palette Genius for macOS\"\u003e\u003cimg align=\"center\" alt=\"Palette Genius\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/27340413-d355-45b2-8f6f-6ac37682d957\"\u003e\u003c/a\u003e\n    \u003ca target=\"_blank\" href=\"https://apps.apple.com/app/6470879005\" title=\"Symbol Scribe for macOS\"\u003e\u003cimg align=\"center\" alt=\"Symbol Scribe\" height=\"52\" width=\"52\" src=\"https://github.com/jaywcjlove/jaywcjlove/assets/1680273/c7249f05-fa70-4def-a1e9-571d5f171fc9\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003chr\u003e\n\nHTMLMinifier\n===\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"}