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

There's JS minification - renaming variables to single letters, eliminating dead code paths, minimising whitespace, etc - that's exceptionally common and will be the default for most frontend workflows.

That is not really 'Obfuscation', at least to the degree that TikTok is doing.



I think the gap between "minimizing" and (un)intentionally "obfuscating" is quite simple: "Sourcemaps". Usually available from all common tools, like Webpack, terser, ..., and the intermediate solution for preserving accuracy.


Of course it is : they are being bad actors by making it harder to read the code. Imagine someone did that in a codebase that you had to take over !

(And sure, there are degrees to this.)


Minfication also reduces the size of the page, resulting in less network traffic.

We used minification on government apps I've worked on before, despite the source being available on GitHub.


After gzip compression, the effect is considerably reduced.


Not really. gzip doesn't know that it can eliminate enormous swaths of unused code paths. I've seen enormous code bases drop from multi-megabyte downloads (even using gzip compression) into mere kilobytes from minification strategies.

It's because minification is far more intelligent than it's made out to be: Your code may pull in a dependency like lodash for a single function in a number of places. gzip would be able to notice that and reduce the total amount of data sent over the wire by de-duplicating and compressing lodash but minification would notice that you're only using a single function and only that function would end up being included in the minified source (and similarly de-duplicated).


Besides removing unused code paths gzip is usually better https://css-tricks.com/the-difference-between-minification-a...


If we broadly include tree shaking (aka dead code elimination) in minification, then yes. They are often considered distinct transformations.


At least in webpack, tree shaking and minimization are distinct, but BOTH include dead code elimination.

For webpack tree shaking is the removal the declarations of exported values that are never imported. Further, imported values that were used used in functions such exported can be removed (although removing the last import from a file entirely requires knowing the imported file has no side effects).

Separately to that the minimizer (terser) has its own dead code elimination process, that performs more in depth analysis. Terser cannot do the tree shaking part itself because of how webpack structures modules that Webpack was unable to concatenate, and because code slitting might make that live in a different file. But if webpack can eliminate unused exports and ensure that split files only access each other via exports, then terser can handleremaining dead code elimination within each module.


> Imagine someone did that in a codebase that you had to take over !

This is typically done at build time, so there's no or little impact to developers writing code.

Minification is the frontend equivilent to compiling code. We typically don't think of building a Go program as 'obfuscating' it when compiling it down to machine code even though the resulting artefact is harder to read than the original source code.




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

Search: