TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why don't modern browsers include precompiled js libraries?

9 pointsby seanicaover 13 years ago
For example, Google recommend using their CDN for a range of js libraries Why doesn't Chrome include these libs as precompiled scripts? On detecting a request for a script hosted on Google CDN, Chrome could check it's precompiled cache first and use it if available. For specific js libraries, this would eliminate some aspects of Sam Saffron's "The jQuery Tax".<p>The release cycles of stable versions of jQuery, jQueryUI, et al, seem to be longer than release cycles of Chrome &#38; Firefox patches, so it kinda seems practical.<p>The only issue I can think of right now is potential js library bugs &#38; vulnerabilities being 'baked into the browser'. However I'm pretty sure things like this can be solved. The first thing that comes to mind is it would be treated like any regular browser bug/vulnerability.<p>Are there any enlightened browser hackers that can explain why this is a bad idea?

4 comments

no_more_deathover 13 years ago
1. Browser computes hash for all JS files loaded, and tallies number of uses.<p>2. JS files that get a certain number of uses get marked for compilation.<p>3. On browser startup, the marked files are recompiled into the binary.<p>4. The modules are pulled in when the browser detects an HTTP requested file matches an existing file.<p>MD5 hashing couldn't be used, due to collision vulnerabilities!<p>I guess the question is whether the browser's JITter is already as fast as compiling javascript into the binary.
chrisackyover 13 years ago
Chrome is light weight, unbloated, it's just one of the reasons why I'd say that it has excelled so quickly.<p>When it starts supporting a tonne of libraries it has to really start beefing up on it's dependencies.<p>So, at what point should Google allow/prevent access to their CDN. Additionally, the CDN is notoriously slow for updating to the latest versions. How would these changes them be rolled out to the browser? Through updates, or just realllly long caching?<p>Plus, this would then turn into a kind of DMOZ, where libraries compete to get included and struggle...<p>Plus the CDN supports multiple versions, does this mean that Chrome would have to support all 22 versions of jQuery?<p>jQuery is <i>not</i> a defacto library. I don't start a project and immediately think, lets include jQuery. However if it was precompiled, in Chrome, then the barrier for making this choice would be lowered, and I might find myself just including it for the sake.<p>I think this is totally unfair to other librariesm and it could quite possibly prevent or at least stifle innovation to some extent, since if the footprint of including jQuery in your application is zero, why not just include it, rather than try some other cool DOM project that's not included in the CDN.
评论 #3607676 未加载
maratdover 13 years ago
JS libraries on the client-side are currently stagnating and will soon be dead, largely, because they won. bind, each, map, filter, etc are now part of the language, with more coming in Harmony. They are becoming less and less necessary. Even animation, the very thing that got them started, can now be done in CSS3. There's no need to include them.
jensnockertover 13 years ago
Because compiling jquery etc. is not expensive compared to the cost of downloading the script. Each version on Google CDN is already only downloaded once if the cache in the browser works correctly, so the cost is minimal.