🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
Installations
npm install @putout/plugin-minify
Developer Guide
Typescript
No
Module System
ESM
Min. Node Version
>=18
Node Version
22.11.0
NPM Version
10.9.0
Score
46.5
Supply Chain
82.5
Quality
81.6
Maintenance
100
Vulnerability
97.9
License
Releases
Contributors
Languages
JavaScript (99.09%)
TypeScript (0.65%)
HTML (0.17%)
WebAssembly (0.05%)
CSS (0.02%)
Svelte (0.01%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
20,705
Last Day
17
Last Week
150
Last Month
651
Last Year
7,261
GitHub Statistics
MIT License
728 Stars
14,968 Commits
40 Forks
11 Watchers
46 Branches
23 Contributors
Updated on Feb 12, 2025
Bundle Size
12.76 kB
Minified
4.27 kB
Minified + Gzipped
Package Meta Information
Latest Version
9.0.0
Package Id
@putout/plugin-minify@9.0.0
Unpacked Size
36.14 kB
Size
9.40 kB
File Count
25
NPM Version
10.9.0
Node Version
22.11.0
Published on
Dec 10, 2024
Total Downloads
Cumulative downloads
Total Downloads
20,705
Last Day
142.9%
17
Compared to previous day
Last Week
50%
150
Compared to previous week
Last Month
18.1%
651
Compared to previous month
Last Year
-46%
7,261
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
@putout/plugin-minify 
🐊Putout plugin adds support of minifiers used in @putout/minify
and minify
.
Install
npm i @putout/plugin-putout -D
Rules
- ✅ apply-template-literal;
- ✅ apply-ternary;
- ✅ convert-array-from-to-spread;
- ✅ convert-const-to-var;
- ✅ convert-if-to-logical;
- ✅ convert-return-to-sequence-expression;
- ✅ convert-strict-equal-to-equal;
- ✅ expand-bindings;
- ✅ extract-body;
- ✅ join-continued-strings;
- ✅ inline;
- ✅ mangle-names;
- ✅ merge-assignment-expressions;
- ✅ merge-loops;
- ✅ merge-variables;
- ✅ remove-return-undefined;
- ✅ remove-var-undefined;
- ✅ shorten-names;j
- ✅ simplify-floor;
- ✅ types;
Config
1{ 2 "rules": { 3 "minify/apply-ternary": "on", 4 "minify/apply-template-literal": "on", 5 "minify/convert-var-to-const": "on", 6 "minify/convert-if-to-logical": "on", 7 "minify/convert-strict-equal-to-equal": "on", 8 "minify/convert-array-from-to-spread": "on", 9 "minify/convert-return-to-sequence-expression": "on", 10 "minify/extract-body": "on", 11 "minify/expand-bindings": "on", 12 "minify/mangle-names": ["on", { 13 "mangleClassNames": true 14 }], 15 "minify/merge-assignment-expressions": "on", 16 "minify/merge-variables": "on", 17 "minify/merge-loops": "on", 18 "minify/remove-var-undefined": "on", 19 "minify/remove-return-undefined": "on", 20 "minify/simplify-floor": "on", 21 "minify/shorten-names": "on", 22 "minify/join-continued-strings": "on", 23 "minify/inline": "on", 24 "minify/types": "on" 25 } 26}
apply-ternary
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1if (a) 2 b(); 3else 4 c();
✅ Example of correct code
1a ? b() : c();
apply-template-literal
Not only short, but also fast:
1// 34.795ms 2for (let i = 0; i < 1_000_000; i++) 3 String(i); 4 5// 28.302ms 6for (let i = 0; i < 1_000_000; i++) 7 i.toString(); 8 9// 24.818ms 10for (let i = 0; i < 1_000_000; i++) 11 `${i}`;
❌ Example of incorrect code
1x.toString();
2String(x);
✅ Example of correct code
1String(x);
convert-if-to-logical
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1if (a) 2 console.log('hello'); 3 4if (b) { 5 console.log('hello'); 6 console.log('world'); 7} 8 9if (a) { 10 console.log(1); 11 console.log(2); 12} else { 13 console.log(3); 14 console.log(4); 15}
✅ Example of correct code
1a && console.log('hello');
2
3b && (console.log('hello'), console.log('world'));
4
5a ? (console.log(1), console.log(2)) : (console.log(3), console.log(4));
convert-const-to-var
❌ Example of incorrect code
1const a = 5;
✅ Example of correct code
1var a = 5;
convert-return-to-sequence-expression
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1() => { 2 d(); 3 return 1; 4};
✅ Example of correct code
1() => { 2 d(); 3 return 1; 4};
convert-strict-equal-to-equal
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1a === b;
✅ Example of correct code
1a == b;
convert-array-from-to-spread
❌ Example of incorrect code
1Array 2 .from(a) 3 .map((x, i) => `${i}: ${x}`);
✅ Example of correct code
1[...a].map((x, i) => `${i}: ${x}`);
extract-body
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1if (x) 2 return; 3 4const hello = () => { 5 return 'world'; 6};
✅ Example of correct code
1if (x) 2 return; 3 4const hello = () => 'world';
expand-bindings
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1const y = 'abc'; 2const x = y; 3const fn = require(x); 4 5const a = 5; 6const b = a; 7const c = b; 8 9fn(c);
✅ Example of correct code
1require('abc')(5);
remove-var-undefined
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1var a = undefined;
✅ Example of correct code
1var a;
remove-return-undefined
❌ Example of incorrect code
1const fn = () => { 2 if (a) 3 return undefined; 4 5 return undefined; 6};
✅ Example of correct code
1const fn = () => { 2 if (a) 3 return; 4};
mangle-names
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1function generate() { 2 const hello = 'hi'; 3 return hello; 4}
✅ Example of correct code
1function generate() { 2 const a = 'hi'; 3 return a; 4}
When you want to preserve class names use
1{ 2 "rules": { 3 "minify/mangle-names": ["on", { 4 "mangleClassNames": false 5 }] 6 } 7}
In this case you will see:
❌ Example of incorrect code
1class Hello { 2 world() { 3 const hello = 'hello'; 4 return hello; 5 } 6}
✅ Example of correct code
1class Hello { 2 world() { 3 const a = 'hello'; 4 return a; 5 } 6}
merge-assignment-expressions
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1a = 'hello'; 2b = 'hello'; 3c = 'hello'; 4d = 'hello';
✅ Example of correct code
1a = b = c = d = 'hello';
merge-variables
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1var a; 2var b;
✅ Example of correct code
1var a, b;
merge-loops
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1for (const aa of a) 2 d.push(aa); 3 4for (const bb of b) 5 d.push(bb);
✅ Example of correct code
1for (const aa of [...a, ...b]) 2 d.push(aa);
simplify-floor
Not only shorter, but faster:
1// 5.027ms 2for (let i = 0; i < 1_000_000; i++) 3 Math.floor(i + 0.5); 4 5// 3.493ms 6for (let i = 0; i < 1_000_000; i++) 7 ~~(i + 0.5);
❌ Example of incorrect code
1Math.floor(x);
✅ Example of correct code
1~~x;
shorten-names
Feats good to @putout/plugin-declare
.
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1const a = (b) => { 2 Object.keys(b); 3}; 4 5const b = (keys) => { 6 Object.keys(keys); 7}; 8 9Object.freeze(a); 10Object.defineProperty(b);
✅ Example of correct code
1const a = (b) => { 2 keys(b); 3}; 4 5const b = (keys) => { 6 Object.keys(keys); 7}; 8 9freeze(a); 10defineProperty(b);
types
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1const a = undefined; 2const b = true; 3const c = false;
✅ Example of correct code
1const a = void 0; 2const b = !0; 3const c = !1;
join-continued-strings
Join continued strings to one line. Check out in 🐊Putout Editor.
❌ Example of incorrect code
1console.log(`\ 2 1\ 3 2\ 4 3`, '\ 5 a\ 6 b\ 7 c');
✅ Example of correct code
1console.log(` 1 2 3`, ' a b c');
inline
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1let x = 1; 2--x; 3 4if (!x) 5 console.log('hello');
✅ Example of correct code
1let x = 1; 2 3if (!--x) 4 console.log('hello');
License
MIT

No vulnerabilities found.
Reason
30 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
no binaries found in the repo
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/nodejs-pr.yml:1
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Info: no jobLevel write permissions found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
4.8
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More