News for hackers. Stuff that matters.
Re:Minification Is Evil by m4rtink on Wednesday November 22, 2023 @10:22AM (#38380447)
Doesn't gzip compression & source maps take care of this withou the abomination that is minification ?
Re:Minification Is Evil by sebstefan on Wednesday November 22, 2023 @10:33AM (#38380596)
Using the largest, unminified, single file I could find in my node_modules folder (which happened to be tsserver.js from typescript, 11mb and 185 000 lines long)

Raw: 11 403KiB

Raw gzipped: 1 881 KiB

Minified: 3 543 KiB

Minified gzipped: 865 Kib

A 2.17x reduction between the two gzips

Even with GZip, minification is huge

Re:Minification Is Evil by umvi on Wednesday November 22, 2023 @10:36AM (#38380631)
Most people aren't making webpages that need a quarter million lines of JS. For a normal sized webpage, difference between raw gzipped and minified gzipped is negligable.

Or maybe even "modern front end" hello world apps now need a quarter of a million lines because "modern" JS devs use super mega react typescript which installs 1000 npm dependencies and requires a 30 second "build" to generate a huge monolithic minified tree-shook js blob. I wouldn't know, I just use vanilla JS for my web pages.

Re:Minification Is Evil by sebstefan on Wednesday November 22, 2023 @10:46AM (#38380775)
Okay. Let's move goalposts.

For a small file (github.com/runk/node-chardet, release version 0.7.0, index.js, 154lines, 4KiB)

Raw - 3.30 KiB

Minified - 2.05 KiB

Gz - 1.01 KiB

Minified+Gz - 0.81 KiB

That's a 25% reduction

Still huge. If minifying before gzipping multiples the size of my transfers by a factor between 0.75 and 0.40, I'm not skipping it for the one oddball that wants the sources in a human-readable format on the production environment

They can use the sourcemaps, or find the files on github

Re:Minification Is Evil by umvi on Wednesday November 22, 2023 @05:17PM (#38385965)
Saving 200 bytes is "still huge"? For me 200 bytes is not worth the extra headaches minification introduces.
Re:Minification Is Evil by sebstefan on Thursday November 23, 2023 @05:54AM (#38391483)
You're the one who complained my examples files were too big.

This is about the general discussion around minification. I don't care the specifics of your particular usecase.

The point is that it reduces filesizes even after gzip. You having an arbitrary threshold around 200 bytes is not interesting.

Re:Minification Is Evil by umvi on Thursday November 23, 2023 @08:03PM (#38399664)
My point is that for most people, the size savings of minification are going to be miniscule because most people are dealing with small JS files. Not only that but it makes debugging a much bigger pain. You start needing to generate and distribute map files, you can no longer easily observe or modify state from Dev console, etc.

I'm not completely opposed to minification. Distributing some self contained library like OpenCV.js? Minify away. But minifying everything even application files under active development just impedes developer velocity IMO for very little benefit. You shave off a couple hundred bytes in exchange for worse development/debugging and ostensibly faster page loads but realistically the same page loads.