Hacker News new | past | comments | ask | show | jobs | submit login

I love the thought behind it, but the sad reality is that browsers prefer minimized code these days. Long and descriptive variable and function names require storage. TypeScript and React generate a lot of verbose code that minifiers chew through (and usually expect that release mode will be minified).

If you want to give your users access to your code, minify (preferably with a minifier that uses newlines where possible) and use source maps.




Browsers don't particularly care about minified vs. unmagnified. Parsing time increases relative to the number of bytes being parsed. If a minified (among other things) strips dead code, that will give you a win.

[source: I wrote the JSC parsers]


Do minifiers typically strip dead code? Beyond removing whitespace and unnecessary semicolons, I know they rewrite some if statements into confusing?alternative:formats that save bytes but do the same thing, but really cutting parts out?

Obviously less non-whitespace data to parse will make the parsing faster, but I would be curious whether it bothers trying to detect dead code. It seems similar to a halting problem, knowing whether something can be reached, but I'm not well-versed enough in that theory to really say much more than this gut feeling.


minifies like typescript compilers, etc can remove dead code.

I recall some minifiers that definitely did - whether they're still in use I don't know (I haven't been working in engine dev for a few years).

For JSC's parsing the most expensive things are strict mode, and certain "errors" which basically trigger a rollback in the parser and then a reparse with more validation.


Other than longer variable names taking up more storage, is there anything built into browsers that actually prefers minified code? The only feature I've seen that's related is the pretty-print a minified file option.

edit: yay source maps!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: