4 ms·
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 st
by mmastrac 6y ago
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.
- raybb 6y agoOther 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!
- olliej 6y agoBrowsers 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]
- lucb1e 6y agoDo 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.
- olliej 6y agominifies 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.