Live data from Hacker News

Minification Is Evil

todepond.com

71–80 of 93 posts

Re: Minification Is Evil

#71
post #19

Earlier quoted context omitted.

It would be nice to have experimentally-derived numbers to point to in order to help people visualize whether or not minification actually improves compression to any significant degree.

Quick test I've done with some popular frameworks. I wonder if minification affects to parsing speed. +--------------------------+---------+---------+---------+--------+ | Library | Size | gzip -1 | gzip -9 | brotli | +--------------------------+---------+---------+---------+--------+ | bootstrap.css | 280813 | 47312 | 33109 | 24533 | | bootstrap.min.css | 232948 | 42003 | 30776 | 22695 | | react.development.js | 875…

> Edit: something important to note: some frameworks (e.g. React) have lots of comments on their un-minified versions, that are removed when minified. That affects their size greatly.

Are you telling us your code doesn't? :-)

Re: Minification Is Evil

#72

Earlier quoted context omitted.

Minification is the "feel good" optimization for frontend (ahem, full-stack nowadays) developers that want to feel like they are doing FAANG-level optimizations.

What would be worthwhile optimisation to do?

For a small/medium site? Optimize images sizes/resolutions & keep the JS dependencies in check to only actually used code, or optimize to get the most important data rendered ASAP are much more important then adding a minifier script in the release pipeline (and I'm assuming gzipping the content is basically done for free everywhere nowadays). All of this especially in the spirit of TFA that encourages people to poke around JS code while browsing websites (as people did in the past with pure HTML)

Re: Minification Is Evil

#73
post #31

Earlier quoted context omitted.

How big is your JS that minification has measurable performance impact? In my experience, minification doesn't add much (if anything) on top of gzip + cache for most applications.

Yeah, the way compression works, I wouldn't expect minification to reduce the transfer sizes to any significant degree, as it's basically layering a good compression algorithm on top of a bad one. In general compression algorithm matroshka dolls tend to be inferior in terms of size and speed when compared to just using one good algorithm.

All of the comments on this post that include numbers show that using both is better than just one or the other, mostly when the code’s sufficiently large.

I agree with the recommendation of one good compression algorithm vs combining multiple in general, but is it possible that you hadn’t considered that this is a case where we have a very good lossless compression (gzip) that can get benefits when combined with a lossy compression (minification)? As wonderful as Huffman codings can be, it’s hard to compete with outright throwing “unnecessary” (to many users, maybe not OP and some of us) data away.

Re: Minification Is Evil

#74

Earlier quoted context omitted.

Quick test I've done with some popular frameworks. I wonder if minification affects to parsing speed. +--------------------------+---------+---------+---------+--------+ | Library | Size | gzip -1 | gzip -9 | brotli | +--------------------------+---------+---------+---------+--------+ | bootstrap.css | 280813 | 47312 | 33109 | 24533 | | bootstrap.min.css | 232948 | 42003 | 30776 | 22695 | | react.development.js | 875…

> Edit: something important to note: some frameworks (e.g. React) have lots of comments on their un-minified versions, that are removed when minified. That affects their size greatly. Are you telling us your code doesn't? :-)

Often I avoid comments by using long names for functions and variables (e.g. the test whose name is a statement of the postulate behind it) and minimization squashes many of those.

Re: Minification Is Evil

#75
post #21

Don’t agree with this take. Sacrificing the performance for all my users so a minuscule percentage of them can poke around a little easier? All the JavaScript is likely transpiled anyway. They can use dev tools to unminify most of it. Deploying with source maps for production might be a better ask?

Hi. Article writer here. Sourcemaps are pants and a nightmare to deal with. I make up for performance in other ways! Let me know if any part of my website(s) run slow

Do you have any strong example websites? The website you linked is very simple, I can’t see why most pages on it would benefit from using JS at all except for analytics or similar. It’s a good website, I don’t mean to make it sound otherwise, but it’s not the type that should consider minifying code in the first place.

Minification’s more useful for web applications, along the lines of: MS Office (e.g. Excel), Zappier, UberEats, Photoshop, the reporting side of analytics (e.g. Google Analytics) where you get all the interactive graphs and maps.

I think many of the disagreements on here would dissolve if they were only considering blogs and similarly small websites.

Re: Minification Is Evil

#76

Earlier quoted context omitted.

Quick test I've done with some popular frameworks. I wonder if minification affects to parsing speed. +--------------------------+---------+---------+---------+--------+ | Library | Size | gzip -1 | gzip -9 | brotli | +--------------------------+---------+---------+---------+--------+ | bootstrap.css | 280813 | 47312 | 33109 | 24533 | | bootstrap.min.css | 232948 | 42003 | 30776 | 22695 | | react.development.js | 875…

> Edit: something important to note: some frameworks (e.g. React) have lots of comments on their un-minified versions, that are removed when minified. That affects their size greatly. Are you telling us your code doesn't? :-)

Hah! It's self-documenting!

Nah, in a more serious note, to properly compare the impact of minification, I should remove the comments from the unminified (maxified?) version first. :)

Re: Minification Is Evil

#77
post #13

Earlier quoted context omitted.

Very few websites have optimised their assets and number of connections enough that the size of the code is the bottleneck. Moreover, code tends to be highly compressible. I doubt it really saves much bandwidth. All javascript build systems out there already does it, though. Not doing it would require people to go out of their way. I think that's ultimately the main reason people do it.

There are different aspects of minification though, right? I don't know if you count tree shaking but I do know my main project at work has 60,000 files in node_modules and if all of those were incorporated in my bundle that would be a big problem. The "modern web stack" just wouldn't work without it. I've done a lot of photo projects where asset optimization is pretty important because it is easy to get in a place w…

Fair enough. All node_modules I've worked with this far has been huge. Including everything is definitely not an option.

Re: Minification Is Evil

#78

Earlier quoted context omitted.

Hi. Article writer here. Sourcemaps are pants and a nightmare to deal with. I make up for performance in other ways! Let me know if any part of my website(s) run slow

Do you have any strong example websites? The website you linked is very simple, I can’t see why most pages on it would benefit from using JS at all except for analytics or similar. It’s a good website, I don’t mean to make it sound otherwise, but it’s not the type that should consider minifying code in the first place. Minification’s more useful for web applications, along the lines of: MS Office (e.g. Excel), Zappie…

Self-reply: I see that the website links to tldraw under Job, which might be a good example to weigh the shipped size vs the same thing minified, except that it's already minified.

As a tangent: this is a neat tool! :)

Re: Minification Is Evil

#79
post #38

Earlier quoted context omitted.

which is actually a security risk

If people seeing your frontend code is a security risk, I've got some bad news for you...

See the source code and interacting with it running is different.

every system has an attack surface. If you make yours easier for any person to use "alternative" paths, I also got some bad news for you.

Re: Minification Is Evil

#80

Earlier quoted context omitted.

Yeah, the way compression works, I wouldn't expect minification to reduce the transfer sizes to any significant degree, as it's basically layering a good compression algorithm on top of a bad one. In general compression algorithm matroshka dolls tend to be inferior in terms of size and speed when compared to just using one good algorithm.

All of the comments on this post that include numbers show that using both is better than just one or the other, mostly when the code’s sufficiently large. I agree with the recommendation of one good compression algorithm vs combining multiple in general, but is it possible that you hadn’t considered that this is a case where we have a very good lossless compression (gzip) that can get benefits when combined with a l…

Does still sort of does come off as majoring in the minors.

As illustrated by the examples in this thread, the actual benefit of this isn't particularly large, and it comes at the expense of worse developer experience. At the point where this would actually have a real measurable performance impact, your application is so hideously bloated there is without a shred of doubt other things you can do to improve the performance of your application that is more impactful than minification.

Post reply on HN