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.
Comments
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.