News for hackers. Stuff that matters.
Re:YouTube artificially slows down video load times when usi... by qwery on Monday November 20, 2023 @06:25AM (#38346449)
Is the use of the "E" notation common in JS? I can see that it (could be) less bytes, obviously more efficient for bigger values... Looking at the script I can see it is minified or whatever we call that these days. I guess my question really is: did someone write "5E3" or did the minifier choose it?

(Sorry this is heading into the weeds, but I'm not really a web developer so maybe someone can tell me!)

Re:YouTube artificially slows down video load times when usi... by sebzim4500 on Monday November 20, 2023 @06:26AM (#38346468)
Almost certainly the minimizer
Re:YouTube artificially slows down video load times when usi... by yread on Monday November 20, 2023 @06:35AM (#38346548)
I wonder if this actually decreases the byte over wire. 5000 compresses a lot better.... sorry for OT
Re:YouTube artificially slows down video load times when usi... by brettermeier on Monday November 20, 2023 @04:09PM (#38354810)
Interesting question. Has anyone tested this?
Re:YouTube artificially slows down video load times when usi... by Dumble on Monday November 20, 2023 @06:27AM (#38346481)
Totally possible that the minifier did this, yes.
Re:YouTube artificially slows down video load times when usi... by d3w4s9 on Monday November 20, 2023 @07:20AM (#38346947)
Because 5E3 is shorter than 5000, just like you can often see !0 to get "true" in minimize code because it saves two characters.
Re:YouTube artificially slows down video load times when usi... by pbhjpbhj on Monday November 20, 2023 @07:50AM (#38347227)
In js I thought 1==true, and 1 is shorter than !0 ??

Never seen the use of exponential notation for numbers in js though (not a surprise, I'm not really a programmer), it seems sensible to me from the point of shifting the domain from ms to seconds.

Re:YouTube artificially slows down video load times when usi... by ayhanfuat on Monday November 20, 2023 @07:59AM (#38347339)
> In js I thought 1==true, and 1 is shorter than !0 ??

`1==true` but `1!==true` (`===` and `!==` check for type equality as well and while `!0` is a boolean, `1` is not.

Re:YouTube artificially slows down video load times when usi... by the_gipsy on Monday November 20, 2023 @08:01AM (#38347356)
Double-equals behaves differently than triple-equals. Minifiers probably can't swap them safely.
Re:YouTube artificially slows down video load times when usi... by neuromanser on Monday November 20, 2023 @12:05PM (#38350613)
!0 === true, but 1 !== true. I don't recall ever needing the strict comparison, but it seems to tickle the fancy of most js programmers.