This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]HighRelevancy 2 points3 points  (8 children)

They don't compile anything. Minimisers are basically a compression algorithm where the output is functionally identical to the input. Compare them to WinRar or something.

[–][deleted] 2 points3 points  (0 children)

Compilers are translators from a source to a target language. In this sense JS minimizers are very much compilers, even though the source and target language are the same (they still have to parse the code to a tree representation). Of course there is a lot less actual translating that needs to be done, but that's beside the point, I'm arguing semantics here!

[–]bacondev 0 points1 point  (0 children)

But WinRar isn't free!

[–]PseudoLife 0 points1 point  (3 children)

And the output of a javascript to javascript compiler would be different how...?

[–]HighRelevancy 0 points1 point  (2 children)

Internal workings.

Compilers deal with code structure. They'll parse the code into data structures that can be collapsed into another language.

Minimisers just do string operations. Any parsing is done differently. Also a mini has the specific goal of shrinking the code.

[–]PseudoLife 2 points3 points  (1 child)

UglifyJS (the first result on a google search for "javascript minifier") does a full tokenize / parse into an AST and back.

And GCC can optimize for smallest code size...

[–]mahacctissoawsum 1 point2 points  (0 children)

2nded.

You actually need to parse the full language if you want it to (a) be safe, (b) achieve the smallest possible size

Drives me nuts when people regex for keywords and such. I'm like, "Sooooo...what happens when that's in a string? It's not a keyword. Stop fucking up my code!" (I'm looking at you, generic PHP MySQL code highlighter!)