{"id":15713764,"url":"https://github.com/sam0x17/html-minifier","last_synced_at":"2025-06-25T17:08:46.408Z","repository":{"id":48068571,"uuid":"212153787","full_name":"sam0x17/html-minifier","owner":"sam0x17","description":"A zero-dependency HTML/CSS/Javascript minifier for the Crystal language","archived":false,"fork":false,"pushed_at":"2021-08-09T07:50:30.000Z","size":182,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-12T22:55:34.939Z","etag":null,"topics":["crystal-language","crystal-shards","css-minifier","html-minifier","javascript-minifier"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/sam0x17.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}},"created_at":"2019-10-01T17:10:23.000Z","updated_at":"2022-10-25T10:24:47.000Z","dependencies_parsed_at":"2022-08-12T17:50:59.483Z","dependency_job_id":null,"html_url":"https://github.com/sam0x17/html-minifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sam0x17/html-minifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam0x17%2Fhtml-minifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam0x17%2Fhtml-minifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam0x17%2Fhtml-minifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam0x17%2Fhtml-minifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sam0x17","download_url":"https://codeload.github.com/sam0x17/html-minifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam0x17%2Fhtml-minifier/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261917437,"owners_count":23229917,"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","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":["crystal-language","crystal-shards","css-minifier","html-minifier","javascript-minifier"],"created_at":"2024-10-03T21:33:18.769Z","updated_at":"2025-06-25T17:08:46.385Z","avatar_url":"https://github.com/sam0x17.png","language":"Crystal","readme":"# html-minifier\n\nhtml-minifier embeds the widely-used [html-minifier](https://www.npmjs.com/package/html-minifier)\nNPM package in an easy-to-use Crystal shard via [duktape.cr](https://github.com/svaarala/duktape),\nwhich provides a fast, embedded Javascript execution environment within Crystal.\n\nhtml-minifier can be used to minify arbitrary HTML content, including Javascript and/or CSS.\n\nSome features:\n* minifies HTML and any embedded CSS/Javascript within the HTML\n* no non-Crystal dependencies (no Node.js or NPM required)\n* all html-minifier Javascript is baked into the shard, so you won't need to package any extra files with your app/tool/library\n* doesn't embed an entire Node.js runtime (Javascript is executed via duktape.cr)\n* simple, Crystal-based API (`HtmlMinifier.minify!(\"source code\")`\n* full support for html-minifier [options](https://github.com/kangax/html-minifier#options-quick-reference) via `HtmlMinifier.set_options`\n* sane, one-size-fits-all options are included by default (unlike html-minifier on NPM)\n\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     html-minifier:\n       github: sam0x17/html-minifier\n   ```\n\n2. Run `shards install`\n\n## Minification\n\n```crystal\nrequire \"html-minifier\"\n\nHtmlMinifier.minify!(\"\u003chtml\u003e  \u003cbody\u003eminify  me!\u003c/body\u003e\u003c/html\u003e\") # =\u003e \"\u003chtml\u003e \u003cbody\u003eminify me!\u003c/body\u003e\u003c/html\u003e\"\nHtmlMinifier.minify!(\"\u003cstyle\u003ebody { background-color: black }\u003c/style\u003e\") # =\u003e \"\u003cstyle\u003ebody{background-color:#000}\u003c/style\u003e\"\nHtmlMinifier.minify!(\"\u003cscript\u003e alert('hello world');\u003c/script\u003e\") # =\u003e \"\u003cscript\u003ealert(\\\"hello world\\\")\u003c/script\u003e\"\n```\n\n## Configuration\nAll options supported by html-minifier on NPM are supported by this shard. Options can be specified\nby a `JSON::Any` object or by a JSON string, as shown below.\n\n```crystal\nrequire \"html-minifier\"\n\nHtmlMinifier.minify!(\"\u003chtml\u003e\u003c!-- comment --\u003e\u003c/html\u003e\") # =\u003e \"\u003chtml\u003e\u003c/html\u003e\"\n\nHtmlMinifier.set_options(\"{\\\"removeComments\\\": false}\")\n\nHtmlMinifier.minify!(\"\u003chtml\u003e\u003c!-- comment --\u003e\u003c/html\u003e\") # =\u003e \"\u003chtml\u003e\u003c!-- comment --\u003e\u003c/html\u003e\"\n```\n\nNote that user-specified options will override their respective default values. The default\nvalues for all options are shown below:\n\n```json\n{\n  \"caseSensitive\": true,\n  \"conservativeCollapse\": true,\n  \"minifyCSS\": true,\n  \"minifyJS\": true,\n  \"useShortDoctype\": true,\n  \"removeTagWhitespace\": true,\n  \"removeScriptTypeAttributes\": true,\n  \"removeComments\": true,\n  \"collapseWhitespace\": true,\n  \"collapseInlineTagWhitespace\": true,\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsam0x17%2Fhtml-minifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsam0x17%2Fhtml-minifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsam0x17%2Fhtml-minifier/lists"}