{"id":24983684,"url":"https://github.com/posthtml/posthtml-minify-classnames","last_synced_at":"2025-10-04T15:46:17.922Z","repository":{"id":44023701,"uuid":"67158897","full_name":"posthtml/posthtml-minify-classnames","owner":"posthtml","description":"📩 Rewrites classnames and ids in HTML and CSS to reduce file size.","archived":false,"fork":false,"pushed_at":"2025-02-20T07:51:00.000Z","size":721,"stargazers_count":88,"open_issues_count":9,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-04T18:35:44.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/posthtml.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,"zenodo":null}},"created_at":"2016-09-01T19:08:50.000Z","updated_at":"2025-07-29T06:23:36.000Z","dependencies_parsed_at":"2024-01-06T21:05:54.084Z","dependency_job_id":"d3df466d-2061-48bc-9b62-eb80f443acdb","html_url":"https://github.com/posthtml/posthtml-minify-classnames","commit_stats":{"total_commits":91,"total_committers":12,"mean_commits":7.583333333333333,"dds":0.7472527472527473,"last_synced_commit":"57188beecd9946f80f111ff50cf8c76b548835c8"},"previous_names":["simonlc/posthtml-minify-classnames"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/posthtml/posthtml-minify-classnames","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-minify-classnames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-minify-classnames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-minify-classnames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-minify-classnames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-minify-classnames/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-minify-classnames/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278335451,"owners_count":25970113,"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":[],"created_at":"2025-02-04T09:20:16.603Z","updated_at":"2025-10-04T15:46:17.881Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"150\" height=\"150\" alt=\"PostHTML\" src=\"https://posthtml.github.io/posthtml/logo.svg\"\u003e\n  \u003ch1\u003eMinify Classnames\u003c/h1\u003e\n  \u003cp\u003eRewrites classnames and ids in HTML and CSS to reduce file size.\u003c/p\u003e\n\n  [![Version][npm-version-shield]][npm]\n  [![Build][github-ci-shield]][github-ci]\n  [![License][license-shield]][license]\n  [![Downloads][npm-stats-shield]][npm-stats]\n\u003c/div\u003e\n\n# About\n\nThis PostHTML plugin minifies classnames and ids, reducing the weight of your HTML.\n\n## Examples\n\n- [Basic](examples/basic.md)\n- [GenName](examples/genName.md)\n\n## Installation\n\n```sh\nnpm i -D posthtml-minify-classnames\n```\n\n## Usage\n\n```js\nimport posthtml from 'posthtml'\nimport minify from 'posthtml-minify-classnames'\n\nconst html = `\n  \u003cstyle\u003e\n    #foo { color: red }\n    .bar { color: blue }\n    .baz { transition: all }\n    .biz { color: green }\n  \u003c/style\u003e\n  \u003cdiv \n    id=\"foo\" \n    class=\"bar\"\n    x-transition:enter=\"baz\"\n    x-transition:enter-start=\"biz\"\n  \u003ebaz\u003c/div\u003e`\n\nposthtml()\n  .use(minify({\n    filter: /^.bar/,\n    genNameClass: 'genNameEmoji',\n    genNameId: 'genNameEmoji',\n    customAttributes: ['x-transition:enter'],\n  }))\n  .process(html)\n  .then(result =\u003e {\n    console.log(result.html)\n  })\n```\n\nResult:\n\n```html\n\u003cstyle\u003e\n  #a { color: red } \n  .bar { color: blue } \n  .b { transition: all }\n  .biz { color: green }\n\u003c/style\u003e\n\n\u003cdiv \n  id=\"a\" \n  class=\"bar\" \n  x-transition:enter=\"b\"\n  x-transition:enter-start=\"biz\"\n\u003ebaz\u003c/div\u003e\n```\n\n### External CSS\n\nTo use with external stylesheets, other plugins must be used, like [posthtml-inline-assets](https://github.com/jonathantneal/posthtml-inline-assets) and [posthtml-style-to-file](https://github.com/posthtml/posthtml-style-to-file), or other build task plugins.\n\n## Options\n\nYou may use an options object to configure the plugin.\n\n### `filter`\n\nType: `RegExp`\\\nDefault: `/^.js-/`\n\nDefine a regular expression that will be used to exclude names from processing.\n\nClasses and IDs that match this will not be minified.\n\n### `genNameClass` \u0026 `genNameId`\n\nType: `Boolean|String`\\\nDefault: `'genName'`\n\nThe name generator to use for classes and IDs.\n\nPossible values:\n\n- `'genName'` - generates the smallest possible names\n- `'genNameEmoji'` - generates small emoji based names\n- `'genNameEmojiString'` - generates random emoji with 3 emojis in each\n- `false` - preserves names, use this to ignore ids or classes\n\n#### Emoji based names\n\nWhile emoji visually looks like a great way to reduce the size of input values, they often use 3-4 bytes or more (some can be over 20 bytes for a single rendered glyph). The below example 3 emoji string values range between 10-12 bytes in size, that's equivalent to ASCII strings up to 12 characters long. \n\nMeanwhile base36(`0-9,a-z`) provides an \"alphabet\" of 36 characters and an equivalent length of 3 characters is more than enough for most users (`36^3 = 46656`).\n\n### `customAttributes`\n\nType: `String[]`\\\nDefault: `[]`\n\nAn array of strings containing custom attribute names that will have their values minified.\n\n### `removeUnused`\n\nType: `Boolean`\\\nDefault: `true`\n\nWhether to remove classes, attributes and other identifiers from the HTML that are not defined in the CSS.\n\nCurrently this only works for values in HTML attributes, it does not remove unused selectors from the CSS.\n\n[npm]: https://www.npmjs.com/package/posthtml-minify-classnames\n[npm-version-shield]: https://img.shields.io/npm/v/posthtml-minify-classnames.svg\n[npm-stats]: http://npm-stat.com/charts.html?package=posthtml-minify-classnames\n[npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-minify-classnames.svg\n[github-ci]: https://github.com/posthtml/posthtml-minify-classnames/actions/workflows/nodejs.yml\n[github-ci-shield]: https://github.com/posthtml/posthtml-minify-classnames/actions/workflows/nodejs.yml/badge.svg\n[license]: ./LICENSE\n[license-shield]: https://img.shields.io/npm/l/posthtml-minify-classnames.svg\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-minify-classnames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-minify-classnames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-minify-classnames/lists"}