News for hackers. Stuff that matters.
Re:Minify and Gzip (2022) by mschuster91 on Monday July 17, 2023 @08:30AM (#36757428)
> Especially things like removing as much whitespace as possible or replacing true/false with !0/!1 just don't really save a lot of space.

At the scale of Wikipedia (~10 billion pageviews a month), even a single byte saving can mean terabytes worth of bandwidth saved.

Re:Minify and Gzip (2022) by distcs on Monday July 17, 2023 @08:36AM (#36757463)
> At the scale of Wikipedia (~10 billion pageviews a month), even a single byte saving can mean terabytes worth of bandwidth saved.

But does it really move the needle anywhere where it matters? If you are serving a million bytes in every response but you manage to trim a single byte from it, I don't think it is going to move the needle anywhere.

Sure it will save a terabyte when you have served a trillion responses. But in a trillion responses you are saving only one terabyte out of an exabyte of responses. That's not much!

Re:Minify and Gzip (2022) by bawolff on Monday July 17, 2023 @02:50PM (#36762375)
Also keep in mind that for big web properties bandwidth is sold very differently than it is to normal consumers.

In many cases wikipedia probably isn't even paying for bandwidth due to peering agreement.

As far as performance goes, i suspect whether a single byte matters depends a lot more on if the extra byte results in the same number of packets or not.

Re:Minify and Gzip (2022) by djbusby on Monday July 17, 2023 @08:40AM (#36757502)
So, why use two bytes for '!0' when just '1' works?
Re:Minify and Gzip (2022) by tinyhitman on Monday July 17, 2023 @08:44AM (#36757539)
Its not strictly the same. '1' is a number whereas '!0' is a boolean.
Re:Minify and Gzip (2022) by ilyt on Monday July 17, 2023 @12:54PM (#36760657)
I hate that language a bit more now
Re:Minify and Gzip (2022) by hn92726819 on Monday July 17, 2023 @08:45AM (#36757566)
Both 1 and true are truthy, but not the same. That would work if the variable was only ever used in if(x), conditions, etc. Stringifying won't produce the same value either when passing values as well.
Re:Minify and Gzip (2022) by cmg on Monday July 17, 2023 @08:56AM (#36757702)
Because 1 !== true and 0 !== false in JavaScript:

  const index = "Hello HN".indexOf("H")
  console.log(index);
  >> 0
  index == false
  >> TRUE
  index === false
  >> FALSE
Re:Minify and Gzip (2022) by foobarbecue on Monday July 17, 2023 @08:53AM (#36757665)
I see this type of reasoning a lot and it feels like it should have its own named fallacy. A tiny percent savings on a huge cost is a moderately big number, yes.

The problem here is that you've switched from proportional thinking to arithmetic thinking in the middle of the thought.

In most cases, if you started with proportional thinking, you should stick to it.

Example of the fallacy: 0.1% of my salary goes to avocado toast, which might not seem that much, but over ten years, that's a thousand dollars!

The fallacy here lies in the fact that a thousand dollars is insignificant over 10 years, but the statement makes it feel significant by switching from proportional to absolute.

"The avocado toast fallacy"?

Re:Minify and Gzip (2022) by fiprofessor on Monday July 17, 2023 @10:03AM (#36758373)
Yes, but sometimes switching to arithmetic/absolute thinking is the right thing to do.

For example, suppose an engineer who is paid $200k per year can spend a week to implement an optimization that reduces costs by 0.1%. If that is 0.1% of something that costs $50 million per year, then that's not a bad use of time.

Re:Minify and Gzip (2022) by distcs on Monday July 17, 2023 @10:58AM (#36759067)
> For example, suppose an engineer who is paid $200k per year can spend a week to implement an optimization that reduces costs by 0.1%. If that is 0.1% of something that costs $50 million per year, then that's not a bad use of time.

Is it not? I don't know. I don't run a multi-million dollar business. So this is an honest question. 0.1% of $50 million is a meagre $50000. If someone is running a business that is spending $50 million per year on something, are they really going to care about a small $50k saving per yera?

Re:Minify and Gzip (2022) by fiprofessor on Monday July 17, 2023 @11:36AM (#36759504)
Well, it's not worth it to bring this optimization to the attention of the CEO. But it definitely exceeds the engineer's weekly cost by a lot, so if it only takes a week, it's potentially worth it (modulo opportunity costs for other things to work on).

Spin it around: is it worth it for a sales person who makes $200k per year to spend a week to land a $50,000 per year contract? I think it potentially is, for the same reason, even if the organization as whole makes hundreds of millions of dollars a year.

Re:Minify and Gzip (2022) by thomastjeffery on Monday July 17, 2023 @12:48PM (#36760555)
Your example is starting with absolute arithmetic, and sticking with it. There is no change.
Re:Minify and Gzip (2022) by asah on Monday July 17, 2023 @01:05PM (#36760838)
google search engineering has entered the chat! https://www.google.com/search?q=google+41+shades+of+blue
Re:Minify and Gzip (2022) by mschuster91 on Monday July 17, 2023 @12:15PM (#36760020)
> A tiny percent savings on a huge cost is a moderately big number, yes.

The thing is, say it takes me an hour to shave off ten bytes in the final build. Value my time per hour at 200$, and the saving of that ten bytes over a year at Wikipedia scale at a thousand dollars, and even investing five times that amount into yak shaving would still be net profitable.

Re:Minify and Gzip (2022) by ilyt on Monday July 17, 2023 @12:53PM (#36760645)
It happens every single time when someone uses big time unit for shock effect
Re:Minify and Gzip (2022) by arp242 on Monday July 17, 2023 @09:06AM (#36757804)
You're right, at some scales it does add up in a meaningful way, and making an informed decision based on that is entirely reasonable. However, most people operate nowhere near that kind of scale, and don't make an informed decision about this.
Re:Minify and Gzip (2022) by tleb_ on Monday July 17, 2023 @09:22AM (#36757950)
Are absolute numbers important in such a case? Percentages seem more appropriate.
Re:Minify and Gzip (2022) by ilyt on Monday July 17, 2023 @12:51PM (#36760619)
Terabyte/month is around 3Mbit/ sec

Remember kids, if someone tries to use unusual time interval (like months for bandwidth-related stuff), they just want to make a small number look big

Re:Minify and Gzip (2022) by dgb23 on Monday July 17, 2023 @03:19PM (#36762701)
Is that correct? I get a larger number.

In either case, they said a single byte saved. Any amount of minification is going to save more than just a byte.

It’s also incredibly low effort to do so.