top | item 38379731

Minification Is Evil

46 points| tpetrina | 2 years ago |todepond.com

89 comments

order

jmull3n|2 years ago

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?

umvi|2 years ago

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.

stetrain|2 years ago

Yep. This is basically like saying "don't distributed compiled binaries"

I'm sure some people here will agree with that sentiment, but for the majority of users it's the better option. And if the goal of the project is for the source to be open then they can host that source somewhere for those who want to tinker, inspect, or build their own binaries.

At some point most web apps will probably be blobs of WASM anyway.

1vuio0pswjnm7|2 years ago

"Sacrificing the performance so a miniscule percentage of them can poke around a little easier?"

Wondering how to reconcile this with the never-ending didactic missives from software developers about writing code that others can easily understand. Generally, the affection for verbose languages and disdain for terse ones.

There is also a trust problem. How can we be sure that minification is only for the purpose of performance and not also for the purpose of obfuscation. For example, from the user's perspective, performance is routinely sacrificed to allow for advertising. Users must wait and allow their computer's resources and network bandwidth to be usurped for telemetry, ad auctions and ads they really do not want to look at. This is almost always orchestrated using Javascript.

shortrounddev2|2 years ago

Or just making the source available on github.

rpigab|2 years ago

My HR web service, used to check if colleagues are on paid leave, has a paginated view of an html table of paid leaves, 30 people per page. A single page contains about 2 million times the character "space", which in the vast majority of html rendering, is completely ignored (exceptions when they actually separate symbols and when they're present in raw text rendered as-is).

There so many more ways to improve performance without minifying code.

humbugtheman|2 years ago

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

PaulHoule|2 years ago

Not minifying your code is evil from the viewpoint of people who have to wait for your page to load.

worble|2 years ago

Isn't this what source maps are for anyway?

Low footprint by default, anyone who wants to inspect then downloads the extra, and for bonus points can even see the original typescripted version instead of the js.

dimitrios1|2 years ago

Or people who cannot afford unlimited data plans.

Preempting because I know we tend to be a little out of touch here: yes there are still plenty of cell plans without unlimited data, mostly among the pay per month options.

m4rtink|2 years ago

Doesn't gzip compression & source maps take care of this withou the abomination that is minification ?

weare138|2 years ago

An easy solution would be integrating a code unminifier/beautifier and viewer into browsers.

humbugtheman|2 years ago

Hi! Website owner here. How quickly did this page load for you?

I make up for performance in other ways.

BanTheBastards|2 years ago

Doesn't really matter after compression unless the bulk of your code can be culled from the end product. Tbh the largest business value this has is slowing down people trying to use your internal APIs.

umvi|2 years ago

IMO, if minification is the difference between a slow and fast page load, it means you aren't utilizing compression. Minification is more obfuscation than anything, it doesn't really bring much to the compression table.

lcnPylGDnU4H9OF|2 years ago

The three lines of not-haiku made me want to write a haiku.

  Do not minify
  Your front end is insightful
  Let people inspect

EGreg|2 years ago

And now, a limerick!

  There once was a proud web designer
  Whose code ‘pared with most was far finer
  Yet he minified
  And nobody spied
  The great masterpiece of Brent Spiner!

Zealotux|2 years ago

I don't understand; I'm not going to increase the size of my assets just to please the very small minority of hackers who want to play around. I'd rather open-source my code.

Michvalwin|2 years ago

Exactly. My largest page before and after minifiying has a size of 78KB~ and 70KB respectively. With GZIP it goes to 13.2KB. Just under the 14KB mark.

meiraleal|2 years ago

which is actually a security risk

donatj|2 years ago

With GZIP and moreso Brotli the difference in actual data transfer is negligible anyway.

Minification doesn't really achieve much other than obfuscation these days.

incrudible|2 years ago

First of all, you're probably bundling your code, stripping comments, have tree-shaking eliminate parts of it. That's already a form of obfuscation. Then, minification will affect performance of parsing, it can even affect whether a function gets inlined by the JIT compiler, because character length is a very cheap heuristic. Whether I care about that or not is my judgement call.

tgv|2 years ago

I just checked: 514kB gzip vs 314kB minified+gzip. Not negligible, IMO.

lagt_t|2 years ago

Not everyone is on 5G. In rural zones and poor countries every kB counts.

sanitycheck|2 years ago

Sadly, not minifying source code can often lead to your idiot customer discovering that their web app is not a magic binary blob and complaining that it's "insecure! anyone can see how it works!", which then in turn leads to your idiot PM agreeing to a new "obfuscate all code" feature without bothering to involve anyone technical.

Deliberately obfuscated JS is far more evil, take it from someone who's had to debug 3rd-party obfuscated JS libs.

gustavus|2 years ago

At that point idiot PMs just need a technical discussion in the closet for an hour having the concept explained to them with a sock full of oranges.

gustavus|2 years ago

Minification always struck me as a cargo culting type way that "badass rockstar programmers would get every last ounce of performance" out of their code.

Because as noted below minification is much less impactful than compression, but going even further, if you really care about performance the solution is as simple as not shoving 20 metric boatloads of JavaScript in your website in the first place.

If you're argument I'd "muh rural customers" then maybe you should actually look at how your website is designed and ask yourself if you need to ship 3 different frameworks to accomplish what you need to do, or maybe start by stripping out the bloated analytics and ad nonsense in your code.

At the end of the day the author is right, the arguments about whether minification is useful is a teachincal argument, but the business will always want it for the purposes of obfuscating their code, and so we need to push back against the idea of it being an industry norm otherwise managers will push to make it so.

JodieBenitez|2 years ago

Hey... good to see this. I was never convinced about this for small to medium JS code base while serving through mod_deflate or similar.

toss1|2 years ago

Soooo long gone are the days of the really compact website

There used to be a contest for best website that would fit into 5k bytes. [0]

Now, the bloat is so bad that there is a serious suggestion to nevermind the website, just make people download the entire cargo load and use it locally, merely to get acceptable performance.

If this does not tell us that the entire framework thing has gone too far, abstracted everything from actual speedy code, larded everything up with so much 'just in case' baggage code, etc... IDK what will.

[0] https://www.the5k.org/

explaininjs|2 years ago

Lots of folks outing themselves as never adding comments with remarks like "compression works nearly as well as minification".

In some of my more logically involved code, the bulk of the bytes are in comments - and they barely compress at all.

Just minify. Nobody cares about your source code; if they do and you want them to, publishing on GitHub is far better as it allows for viewing the TS/ESNext version and separate files too (don't tell me you aren't bundling!!); and working with minified code is not hard, especially now that dev tools have built-in maxifiers.

humbugtheman|2 years ago

Poem author here.

I publish to github too! It's nice to let people download my stuff and tinker though, straight from the website itself :) They can also tinker there and then in the browser.

I'm not trying to convince you either way – it's clear we have a different set of values.

tpetrina|2 years ago

In the modern era of minifying JS to squeeze out bytes, in certain cases, for smaller, non-commercial sites, it might be better for devs to learn from reading each other's source code.

qwery|2 years ago

This is cute. It's refreshing to see such a simple idea published on the internet in such a way. I also got a kick out of the URL.

Thanks for submitting it!

nsonha|2 years ago

Why is everything on the web has to serve some random tinkerer who do not benefit the creator of the website in any way? How about we apply this thinking to other kind of products? An app has to be designed for tinkerers to? A cars, a rockets?..., so everything has to be open source? Why?

stared|2 years ago

I have my personal website on GitHub. It gives much more than "not minified code". And actually, I had one interesting email on a widget I created (weighted sorting of blog posts, so it is up to the user to weigh novelty, popularity, my opinion, etc).

Havoc|2 years ago

Surely better tools to analyse stuff is a better answer.

Think ASM disassemblers - arguably a harder task and people do fine with it

Veuxdo|2 years ago

Think of the lives lost to javascript minification.

eloy|2 years ago

I think minification should be done on another layer: HTTP compression and HTTP parallelization and that kind of stuff. And just don't make a complex web app, so it will be fast.

incrudible|2 years ago

> just don't make a complex web app, so it will be fast

I never thought about that, I will just tell my customers that I removed all non-trivial features to make the app load faster. Also, there won't be any new features. I'll report back on how it goes.

djaouen|2 years ago

Didn’t read the article, but I agree with the title lol

elaus|2 years ago

Not much to read really, it's not even an "article".

But I agree, there is not really much point to minification for small or medium websites. Transport compression takes care of file sizes.

colesantiago|2 years ago

Hard disagree.

Nobody cares about the source, let website authors do what they want.