Jason Knight
1 min readJul 15, 2020

--

Laughably due to the overhead of the callback function on each loop, filter is more often than not SLOWER than looping... though nowhere near as bad as Array.foreach in that regard.

But that's like how arr[arr.length] = a; is faster than push, and if you maintain your own separate counter it can be even faster.

Though creating a unique Iterator is often even faster. .. as is -- believe it or not -- a normal for loop over for/of.

That normal old-fashioned loops in situations like this can be faster than for/of says all sorts of crazy shit about how badly written JavaScript engines must be. But then JavaScript on a whole is utterly nutters and counter-intuitive as to what is fast and what should be fast -- even for ASM programmers like myself. It's like they specifically optimize bad code to behave well and good code to behave... meh.

More so with this arrow function trash and "callbacks for everything" attitude in the mix.

Also you mention HTTP2, but don't actually DISCUSS the push technology. Simply using HTTPS on the HTTP/2 protocol does NOT automagically provide improvements.

NOT that push is a be-all end-all solution given how you end up either NOT caching subfiles that should be cached, or adding overhead to all file processing and all page-loads to make it not push more than once.

--

--

Jason Knight
Jason Knight

Written by Jason Knight

Accessibility and Efficiency Consultant, Web Developer, Musician, and just general pain in the arse

No responses yet