Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Minifying the code does not optimize it in any way. It just makes it more compact (and less readable)."

The thing with JavaScript is that the initial time for loading and parsing a script in the browser counts as part of the performance. This is why every implementation (except for CL-JavaScript: http://svrg.net/CL-Javascript%200.10.05.html) hasn't moved to compilers but JITs instead. So minifying JS does have some performance benefit in that it reduces load and parse time.



Unless your JS parser is absurdly broken, ignoring whitespace should not be such a computationally intensive task. The improvements you see must derive mostly from the size reduction and download time improvement.

And no. Minification of JS would not count as code optimization in any self-respecting compsi course.


"Unless your JS parser is absurdly broken, ignoring whitespace should not be such a computationally intensive task."

It is because every character the parser reads is a loop iteration at best, a state machine transition at worst. Minification does more than just deleting whitespace - identifiers are shortened too.

"The improvements you see must derive mostly from the size reduction and download time improvement."

The former yes because more code fits in cache and you need less time to parse it, the latter no because gzip compression does a better job than minification.

"And no. Minification of JS would not count as code optimization in any self-respecting compsi course."

This is why you learn about compilers by writing them instead of taking courses.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: