Ask HN: Why don't browsers pre-include popular JavaScript libraries?
3 by davnicwil | 1 comments on Hacker News.
I've often wondered why there isn't a standard for browsers having a pre-populated local cache of very popular JS libraries. To name a few examples: jQuery, Lodash, React. It seems like the benefits of this would be significant for both user and developer - faster loading, lower bandwidth, quicker builds, etc. It also seems eminently doable, technically. One possible high-level implementation off the top of my head: - A standard index of the most popular libs is maintained. - You pull them in via the script tag, with a new lib="name@version" attribute. Older browsers can use the src tag as a backup. - SPA build systems like webpack et al are aware of the standard and can just not bundle libs pulled this way, while keeping the require() and import syntax. I do, however, see some pretty big not-strictly-technical difficulties: - The index would have to be administered by some entity. Who would that be, and who would pay for it? - Who defines what the most popular libs are? Whatever system is used, how do you prevent it being gamed to the advantage of particular libs? - Trust and security. A similar set of issues npm faces. Although that being the case, is this really introducing a new problem? It also seems like a much narrower problem if we're only talking about a small set of very popular libs. - Maybe some issues around licensing, bundling code into browsers etc. But again, if it's a smallish set of only very popular libs, this seems like it could be dealt with individually for each one and its authors, maybe as a prerequisite for getting included in the index. These difficulties are not insignificant, but nor do they seem insurmountable and also the benefits do seem genuinely worth it. It just appears to me to be something that should so obviously have been done, that there must be really good reasons why it hasn't been - maybe including those above, maybe technical, maybe others. Does anyone know if any serious attempt has ever been made at a proposal to do something like this, even if in a non-standard way by an individual browser vendor?
New ask Hacker News story: Ask HN: Why don't browsers pre-include popular JavaScript libraries?
Abubakar Mahmoud Sadiq
0
Comments
Tags
Hacker News
Post a Comment