5 ms·
Not minifying your code is evil from the viewpoint of people who have to wait for your page to load.
by PaulHoule 3y ago
Not 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]
- worble 3y agoIsn'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.
- BanTheBastards 3y agoDoesn'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.
- kibwen 3y agoIt 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.
- TheMaskedCoder 3y agoHere's an old article: https://css-tricks.com/the-difference-between-minification-and-gzipping/ https://css-tricks.com/the-difference-between-minification-a... In the example given: Original - 147 KB Minified - 123 KB (83%) Gzipped - 22 KB (15%) Both - 20KB (14%) Compression is waaay more effective, so if you have to pick one, go with compressing. Is having readable source code worth the other 2KB? That's up to you. Source maps can do the same thing with less, though. Also, modern devtools have ways of de-minification (if you don't mind all the mangled variable names).
- ruszki 3y agoI've seen the same thing with different jQuery versions: https://stackoverflow.com/questions/3239125/is-there-any-point-to-javascript-minification-if-you-have-compression-turned-on https://stackoverflow.com/questions/3239125/is-there-any-poi... At least with jQuery, it seems that minification matters considerably.
- tecleandor 3y agoQuick 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 | 87574 | 28733 | 23513 | 19818 | | react.development.min.js | 25612 | 10217 | 9224 | 8052 | | tailwind-2.2.19.css | 3642321 | 376787 | 304100 | 82049 | | tailwind-2.2.19.min.css | 2934019 | 354063 | 294632 | 72803 | | vue.global.js | 476920 | 134655 | 105130 | 87121 | | vue.global.min.js | 167898 | 74769 | 65582 | 57922 | +--------------------------+---------+---------+---------+--------+ 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.
- weare138 3y agoAn easy solution would be integrating a code unminifier/beautifier and viewer into browsers.
- incrudible 3y agoSource maps are a thing, which has the added benefit of letting you ship the comments if you actually care to educate your users on how your website works.
- m4rtink 3y agoDoesn't gzip compression & source maps take care of this withou the abomination that is minification ?
- sebstefan 3y agoUsing 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
- umvi 3y agoMost 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.
- deleted 3y ago[deleted]
- sebstefan 3y agoOkay. 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
- umvi 3y ago
- humbugtheman 3y agoHi! Website owner here. How quickly did this page load for you? I make up for performance in other ways.
- swells34 3y agoIt seems you've stirred up the minification cargo cult, who all seem to be ignoring the actual performance data vs compression . Thank you for the article!
- umvi 3y agoIMO, 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.