butternut
butternut copied to clipboard
The fast, future-friendly minifier
```js // input if ( x ) { foo = 1; } else { foo = 2 } // output x?(foo=1):(foo=2) // better output foo=x?1:2 ``` ```js // input if...
```js // input function foo () { function bar () { console.log(42); } bar(); } // output function foo(){function a(){console.log(42)}a()} // better output function foo(){console.log(42)} ``` I think this basically...
If a variable has a literal value then in many cases it makes sense to inline the value, rather than declaring the variable: ```js // input var COUNT = 99;...
`(function () {}()}` can have no effect, and should be removed
Hey, Great lib :+1:. I was checking the online tool and I noticed that: `(function (xyz) {});` gave the output: `(function(a){})` I expected to receive: `(function(){})`
This can have a substantial impact on generated code size. Would like it to be automated though — no annotations or white/blacklists, instead Butternut should ideally be smart enough to...
If there's an `import`/`export` declaration, we know that this is a module and that it's therefore safe to a) mangle/remove top-level declarations, and b) remove 'use strict' pragmas. Probably makes...
In this example: ```js let foo = false; if (foo) console.log('ohno'); ``` The whole `if` block should get removed. This is very useful for removing development only code blocks from...
*Edited: no longer a bug, but suboptimal output* ```js // input (function () { var {foo,bar} = obj; console.log(foo); }()) // expected !function(){var {foo:a}=obj;console.log(a)}() // or maybe !function(){console.log(obj.foo)}() // actual...
Although butternut appears to be much faster than uglifyjs, it would be nice to also see memory comparisons. I've got a few tasks where uglifyJS gives me no problems, but...