Hacker News new | ask | show | jobs
by GycDH6mb 1620 days ago
> It seems like many of the variables are given names that are not descriptive at all to make it a bit more difficult to read.

The code is just minimized for prod..

The article as written makes it sound like the developer(s) intentionally wrote their code cryptically, whereas minimization for deployment is fairly standard practice

2 comments

How common is it to have your minifier change symbol/variable names to short ones?
Pretty much all of them do it. You can’t minify keywords or literals, so that just leaves whitespace, which would be barely any minification at all.
Jsmin cited a typical 50% reduction without touching symbols, though perhaps that's an average that included removing comments.
I just popped open DevTools on an SPA I made using create-react-app with default settings. Sure enough the minified production JavaScript uses shortened variable names. This is default configuration for Webpack, which is pretty widely used throughout (and outside) the React ecosystem.

Interestingly you can still view the unminified source, since create-react-app generates source maps by default.

It is pretty common. The goal of the minifier is to reduce the size of the file, so taking the function names, variable names, etc and making them as short as possible works towardd that goal
Closure Compiler (for JavaScript) does it. With the SIMPLE_OPTIMIZATIONS [0] flag, it will rename parameters for—and variables local to—functions to save space.

[0]: https://developers.google.com/closure/compiler/docs/compilat...

I've seen some minifiers that can restructure your code... replace if{} with a ternary ?: operator or use boolean shortcutting to replace the whole conditional with a ||, and so on. It's supposed to never do anything that actually affects the logic, but that sort of stuff scares me.
Very common
That's literally what they are for.
For some context, it didn't used to be terribly common. There's a fair amount of minifying that you can do without touching symbol names, though obviously it doesn't help as much as shortening them. The old jsmin cited about 50% reduction, and it didn't touch any variable or class names.
It's actually pretty standard
If they really wanted to hide it, there are some nasty obfuscators for JavaScript: https://obfuscator.io/
https://jsfuck.com is another good one