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

I am honestly not sure why do people minify javascript in electron apps.

It doesn’t really bring any advantage? You need to package whole Chrome with your app, the few MB you save with minification does not matter??

But people here can enlighten me.



Minification helps the parser too, try running VS Code from sources and you’ll notice startup is significantly slower.


huh I would think there is no measurable difference there.

However I honestly have no idea how much time does JS parser spends on what exactly. Are longer variable names and less tabs that big of a deal? It’s all in memory anyway, no… the lexer or tokenizer or whatever (…I never finished my compiler course…) just goes through that


Without nonlinearities like optimization/type checking/etc, the runtime is basically just the time to loop through the bytes. Make the input a quarter the size and you have a quarter the bytes to loop through. College classes will say “oh it’s all O(N) anyways, no big deal”. Industry on the other hand says “why make tens of millions of people wait 4 seconds for this to start when we could make them wait 1 second just as easily”.

The product’s source maps are publicly available in a way the debugger understands and the original code is freely accessible so there’s no real downside.


My best guess is maybe faster hash-map lookups on variable names?


Minification also does some tree-shaking, which results in unused branches and libraries being pruned ( and therefore not needing to be loaded into memory ) and a smaller source size. Some constants can be inlined, which leads to faster execution times as there is no need to wait for a variable to be bound as its value is just written directly into the source everywhere it appears.




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

Search: