{"name":"minify","version":"15.0.0","keywords":["minify","minimize","js","css","img","html","base64"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"minify@15.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"http://coderaiser.github.io/minify","bugs":{"url":"https://github.com/coderaiser/minify/issues"},"bin":{"minify":"bin/minify.js"},"dist":{"shasum":"4a11578945f3182aea164a586e9465c02772e142","tarball":"http://registry-npm.ywwl.com/minify/download/minify-15.0.0.tgz","fileCount":15,"integrity":"sha512-Ultmui0hTYhp/zKOsDhFUfCi7+PuSEz3Jd7ER2Oh1IW2U5WIAp16SXqdIGS6VAmFKMoDD6/oC3Sp0kckU9iQUA==","signatures":[{"sig":"MEQCIEWkLZouGupKH77n1KEVg149IWbwNqjjXUU+k8wG6lypAiBskYxs3I+BHLnhZe1mmArGwXn3oj/OCqGrq/rHIe51UQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39724,"size":12581,"noattachment":false,"key":"/minify/-/minify-15.0.0.tgz"},"main":"lib/minify.js","type":"module","engines":{"node":">=22"},"gitHead":"7d603520fcfda943d62bd9fa6dcb4a872be68802","scripts":{"lint":"madrun lint","test":"madrun test","putout":"madrun putout","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","lint:bin":"madrun lint:bin","lint:lib":"madrun lint:lib"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"repository":{"url":"git+ssh://git@github.com/coderaiser/minify.git","type":"git"},"_npmVersion":"11.4.2","description":"Minifier of js, css, html and img","directories":{},"_nodeVersion":"25.2.1","dependencies":{"debug":"^4.1.0","montag":"^1.2.1","terser":"^5.28.1","esbuild":"^0.27.2","find-up":"^8.0.0","simport":"^1.2.0","readjson":"^2.2.2","@swc/core":"^1.6.7","clean-css":"^5.0.1","try-catch":"^4.0.7","lightningcss":"^1.28.1","try-to-catch":"^4.0.3","@putout/minify":"^6.0.0","css-b64-images":"~0.2.5","html-minifier-next":"^4.16.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.3.0","madrun":"^12.1.0","putout":"^41.5.3","escover":"^5.0.1","supertape":"^12.0.0","eslint-plugin-putout":"^29.2.4"},"_npmOperationalInternal":{"tmp":"tmp/minify_15.0.0_1767559931226_0.22087933210914001","host":"s3://npm-registry-packages-npm-production"},"readme":"# Minify [![License][LicenseIMGURL]][LicenseURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![NPM version][NPMIMGURL]][NPMURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/minify.svg?style=flat\n[BuildStatusURL]: https://github.com/coderaiser/minify/actions\n[BuildStatusIMGURL]: https://github.com/coderaiser/minify/workflows/CI/badge.svg\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[NPM_INFO_IMG]: https://nodei.co/npm/minify.png?stars\n[NPMURL]: http://npmjs.org/package/minify\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n[CoverageURL]: https://coveralls.io/github/coderaiser/minify?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/minify/badge.svg?branch=master&service=github\n\n[Minify](http://coderaiser.github.io/minify \"Minify\") - a minifier of `js`, `css`, `html` and `img` files.\n\nTo get things done **Minify** uses these amazing tools:\n\n- ✅ [@putout/minify](https://github.com/putoutjs/minify);\n- ✅ [html-minifier-next](https://github.com/j9t/html-minifier-next);\n- ✅ [clean-css](https://github.com/jakubpawlowicz/clean-css);\n- ✅ [lightningcss](https://lightningcss.dev/);\n- ✅ [css-base64-images](https://github.com/Filirom1/css-base64-images);\n\n## Install\n\nFor Node users:\n\n```sh\nnpm i minify -g\n```\n\nFor Deno users:\n\n```js\nimport {minify} from 'npm:minify';\n```\n\n## How to use?\n\n### CLI\n\n```sh\nUsage: minify [options]\nOptions:\n  -h, --help                  display this help and exit\n  -v, --version               display version and exit\n  --js                        minify javascript\n  --css                       minify css\n  --html                      minify html\n  --auto                      auto detect format\n```\n\nThe bash command below creates a code snippet saved as `hello.js`.\n\nSimply copy + paste the code starting with cat, including the EOT on the last line, and press <enter>.\n\n```sh\n$ cat << EOT > hello.js\nconst hello = 'world';\n\nfor (let i = 0; i < hello.length; i++) {\n    console.log(hello[i]);\n}\nEOT\n```\n\nUse the command `minify` followed by the path to and name of the js file intended to be minified. This will minify the code and output it to the screen.\n\n```sh\n$ minify hello.js\nvar a='world';for(let i=0;i<a.length;i++)console.log(a[i]);\n```\n\nYou can capture the output with the following:\n\n```sh\n$ minify hello.js > hello.min.js\n```\n\nUse `--fail-on-error` to get a non-zero exit code when minification fails (useful in build scripts and CI):\n\n```sh\n$ minify broken.js --fail-on-error > broken.min.js\n$ echo $?\n1\n```\n\nYou can pass input using `cat`:\n\n```sh\ncat << EOT | bin/minify.js --js\n> const hello = 'world';\n>\n> for (let i = 0; i < hello.length; i++) {\n>     console.log(hello[i]);\n> }\n> EOT\nvar a='world';for(let i=0;i<a.length;i++)console.log(a[i]);\n```\n\n`Minify` can be used with `async-await` and [try-to-catch](https://github.com/coderaiser/try-to-catch):\n\n```js\nimport {minify} from 'minify';\nimport {tryToCatch} from 'try-to-catch';\n\nconst options = {\n    html: {\n        removeAttributeQuotes: false,\n        removeOptionalTags: false,\n    },\n};\n\nconst [error, data] = await tryToCatch(minify, './client.js', options);\n\nif (error)\n    return console.error(error.message);\n\nconsole.log(data);\n```\n\n## Options\n\nFor cli use these options can be provided in a JSON file named `.minify.json` like so:\n\n```json\n{\n    \"js\": {\n        \"type\": \"putout\",\n        \"putout\": {\n            \"quote\": \"'\",\n            \"mangle\": true,\n            \"mangleClassNames\": true,\n            \"removeUnusedVariables\": true,\n            \"removeConsole\": false,\n            \"removeUselessSpread\": true\n        }\n    },\n    \"img\": {\n        \"maxSize\": 4096\n    },\n    \"html\": {\n        \"removeComments\": true,\n        \"removeCommentsFromCDATA\": true,\n        \"removeCDATASectionsFromCDATA\": true,\n        \"collapseWhitespace\": true,\n        \"collapseBooleanAttributes\": true,\n        \"removeAttributeQuotes\": true,\n        \"removeRedundantAttributes\": true,\n        \"useShortDoctype\": true,\n        \"removeEmptyAttributes\": true,\n        \"removeEmptyElements\": false,\n        \"removeOptionalTags\": true,\n        \"removeScriptTypeAttributes\": true,\n        \"removeStyleLinkTypeAttributes\": true,\n        \"minifyJS\": true,\n        \"minifyCSS\": true\n    },\n    \"css\": {\n        \"type\": \"clean-css\",\n        \"clean-css\": {\n            \"compatibility\": \"*\"\n        }\n    }\n}\n```\n\n**Minify** walking up parent directories to locate and read it’s configuration file `.minify.json`.\n\n### `js`\n\nIn section related to `js` you can choose `type` of minifier:\n\n- [`putout`](https://github.com/putoutjs/minify#readme); (default);\n- [`terser`](https://github.com/terser/terser#minify-options);\n- [`esbuild`](https://esbuild.github.io/);\n- [`swc`](https://swc.rs/docs/configuration/minification);\n- [`oxc`](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination.html);\n\nWhen you want to pass [options](https://github.com/terser/terser#minify-options) to `terser`, use section with the same name, `.minify.json` will look this way:\n\n```json\n{\n    \"js\": {\n        \"type\": \"terser\",\n        \"terser\": {\n            \"mangle\": false\n        }\n    }\n}\n```\n\n## License\n\nMIT\n","publish_time":1767559931398,"_cnpm_publish_time":1767559931398,"dist-tags":{"latest":"15.3.1"}}