So even with today's browser and JavaScript improvements that 20kb should still be avoided if possible. Why?
- Each file downloaded adds latency. This especially hurts if you're on a satellite or similar, highly latent connection. The more files you have to download the worse start-up and various loading timing can get.
- Okay, so let's say you minified and combined everything to help avoid the first issue, now you have a new issue: all JavaScript needs to get executed when included. So adding 20kb worth of JavaScript, while not all of it is executed immediately, a chunk of it is. This adds to start-up time.
- Don't forget JavaScript execution, when compared to a desktop, is absolutely abysmal. For mobile web browsers you need to shave as much time off of start-up and ready states as possible.
I don't know, man. The average web page size is now around 2.5MB [1], jQuery is <1% of that. I am not going to be less productive to shave off 1% of total page size. If that means that some random satellite user has to wait 101s instead of 100, so be it. To me, that's much ado about nothing.
jQuery is also not doing a whole lot on startup, its functions get called when needed. Lodash is the same.
> The average web page size is now around 2.5MB [1], jQuery is <1% of that. I am not going to be less productive to shave off 1% of total page size.
2.5MB is absolutely ridiculous. Regardless, you just created a straw-man. jQuery is, what, 26kb minified + gzipped? So you could also say that if website is 100kb then jQuery is 25% the size of your website.
Now 26kb is not much at all but small things add up very quickly. If you're not using it, don't include it. If you can write a tiny bit of extra code to avoid a dependency that isn't highly specialized (e.g. moment.js) it's usually a good idea on the web.
> If that means that some random satellite user has to wait 101s instead of 100
FYI satellite connection issues are more about latency than bandwidth. Adding an extra connection (if it's not concatenated) to fetch jQuery can easily add more than 1 second even though it's only 26kb. Also, I sure hope your app doesn't take 100 seconds to start-up :)
A satellite connection is an example of a highly latent connection. I've seen issues which have caused all sorts of other types of connections to spike with high latency. It's important, in my opinion, for your site to be able to handle that (and honestly it's not that hard).
Satellite in a bit of a red herring in terms of the point I wanted to convey.
I also spent about 3 years working on systems that had to work across satellite connections so I have a little bias as well :)