News for hackers. Stuff that matters.
Re:JavaScript Minification Benchmarks by evmar on Saturday February 06, 2021 @04:43PM (#26050251)
This whole page is weirdly similar to a project I did, for the same purpose:

https://evmar.github.io/js-min-bench/

What I discovered there is that the best minification is one where you just produce an empty file -- it's 0 bytes of output and extremely fast.

And if you say "wait, I have have the additional requirement that you didn't break the code in the original file, obviously!", you then must define what exactly "break" means in that requirement-- for example, it could be that some user requires that someFunction().toString().charAt(10) == 'a', in which case even removing whitespace counts as breakage.

You might think the above is just being overly pedantic or pathological, but it demonstrates a principle that actually ends up mattering, which is that you can't evaluate a minifier unless you define what a successful minification even means. Particularly in the case of more advanced transformation.

I went into it more in this post:

http://neugierig.org/software/blog/2019/04/js-minifiers.html

Re:JavaScript Minification Benchmarks by emptysea on Saturday February 06, 2021 @08:30PM (#26051805)
I think your example should instead be:

    someFunction.toString().charAt(10) == 'a'
so you're getting the function's string representation, not its return value

Also I've never even considered that minifiers can break your code.

To be safe it seems you either need to run minification during test & dev or setup some linting to ban features that could break during minification.

Re:JavaScript Minification Benchmarks by evmar on Monday February 08, 2021 @05:54PM (#26071423)
You are totally right, thanks for catching my mistake.

My blog post linked above goes more into the consequences -- ideally you'd formally define what the allowable language subset is.

Re:JavaScript Minification Benchmarks by bmm6o on Saturday February 06, 2021 @09:49PM (#26052196)
You're not wrong, but if your code breaks when you apply the simplest refactorings you probably aren't thinking about minifying your code. And while Javascript does let you put yourself in that position, I've never seen it in production code. Angularjs dependencies are a notable exception, and have a backup mechanism.
Re:JavaScript Minification Benchmarks by jiofih on Saturday February 06, 2021 @04:52PM (#26050323)
Sorry but what do you mean by “weirdly similar”? It’s a benchmark of minifiers against popular libraries, what’s the creative part?
Re:JavaScript Minification Benchmarks by yoz-y on Saturday February 06, 2021 @05:26PM (#26050615)
I guess a reasonable requirement for a momifier would be that the test suite passes 100% of tests after minification.
Re:JavaScript Minification Benchmarks by fnordsensei on Sunday February 07, 2021 @04:08AM (#26053714)
Except yours include results for Closure in advanced mode, which is enlightening.