8 ms·
Minification Is Evil
- tpetrina 3y agoIn 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.
- djaouen 3y agoDidn’t read the article, but I agree with the title lol
- elaus 3y agoNot 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.
- PaulHoule 3y agoUsually I am telling X users they should quit X and start a blog but this is a blog post that would be better on X and better still on Mastodon. I was on a brief kick of interest in https://en.wikipedia.org/wiki/E-Prime https://en.wikipedia.org/wiki/E-Prime which of course eliminates structures like "X is Y" but I realized I could still write stuff like "With utmost evil, evil webmasters minify their evil web sites for evil reasons that make sense only in the evil world view of evil people"
- darkwater 3y agoMinification is the "feel good" optimization for frontend (ahem, full-stack nowadays) developers that want to feel like they are doing FAANG-level optimizations.
- falserum 3y agoWhat would be worthwhile optimisation to do?
- darkwater 3y agoFor 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)
- PaulHoule 3y agoNot minifying your code is evil from the viewpoint of people who have to wait for your page to load.
- dimitrios1 3y agoOr 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.
- aflag 3y agoVery 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.
- PaulHoule 3y agoThere 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 where your site costs 4x as much to run as it should and just as easy to get in a place where you compressed files too much and your images suck. I am getting into WebXR and facing even tougher problems of asset optimization since I do want to support 90 fps on the not-too-terribly-fast generic ARM Meta Quest 3. I'm sure there is more than one reason you can't upload images to Horizon Worlds but avoiding too many textures with too much detail has to be one of them.
- aflag 3y agoFair enough. All node_modules I've worked with this far has been huge. Including everything is definitely not an option.
- deleted 3y ago[deleted]
- lcnPylGDnU4H9OF 3y agoThe three lines of not-haiku made me want to write a haiku. Do not minify Your front end is insightful Let people inspect
- EGreg 3y agoAnd 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!
- JodieBenitez 3y agoHey... good to see this. I was never convinced about this for small to medium JS code base while serving through mod_deflate or similar.
- colesantiago 3y agoHard disagree. Nobody cares about the source, let website authors do what they want.
- Zealotux 3y agoI 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.
- meiraleal 3y agowhich is actually a security risk
- kevsim 3y agoIf people seeing your frontend code is a security risk, I've got some bad news for you...
- KPGv2 3y agothe implicit argument you're making here is that the only acceptable security risk mitigation strategy is one that works 100% of the time
- meiraleal 3y agoSee 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.
- Michvalwin 3y agoExactly. 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.
- donatj 3y agoWith GZIP and moreso Brotli the difference in actual data transfer is negligible anyway. Minification doesn't really achieve much other than obfuscation these days.
- lagt_t 3y agoNot everyone is on 5G. In rural zones and poor countries every kB counts.
- incrudible 3y agoFirst 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.
- marcosdumay 3y ago> character length is a very cheap heuristic Unless your interpreter is trying to optimize text blocks, op-code length will be cheaper and way easier to develop.
- incrudible 3y agoThe existence of interpreter opcodes implies you have already compiled the code for the interpreter, but with this heuristic you can send this function straight to JIT.
- tgv 3y agoI just checked: 514kB gzip vs 314kB minified+gzip. Not negligible, IMO.
- donatj 3y agoHow big was your original JS package that it gzipped down to 514kB? Like 30 megs? Really sounds like you have bigger problems.
- jmull3n 3y agoDon’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?
- shortrounddev2 3y agoOr just making the source available on github.
- umvi 3y agoHow 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.
- vxxzy 3y agoGiven enough request it could add up. Maybe not big savings for a majority of sites though.
- marginalia_nu 3y agoYeah, 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.
- robinson7d 3y agoAll 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.
- eloy 3y agoI 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 3y 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.
- eloy 3y agoLet me rephrase: > just don't make a unnecessarily complex web app, so it will be fast Lots of apps include features that were never really asked for by the customer, but are included because it was easier for the developer.
- incrudible 3y agoNo.
- toss1 3y agoSoooo 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/ https://www.the5k.org/
- stared 3y agoI 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).
- sanitycheck 3y agoSadly, 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 3y agoAt 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.
- sanitycheck 3y agoFinally, a good reason to return-to-office.
- gustavus 3y agoMinification 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.
- Veuxdo 3y agoThink of the lives lost to javascript minification.
- qwery 3y agoThis 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!
- Havoc 3y agoSurely better tools to analyse stuff is a better answer. Think ASM disassemblers - arguably a harder task and people do fine with it
- explaininjs 3y agoLots 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 3y agoPoem 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.
- nsonha 3y agoWhy 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?