Post

wouldn't it be nice if sites could share a cache of common js? ... stuff like react, or vue or svelte? 👉 there's an early stage proposal for cross-origin storage which enables exactly this. there are challenges but I think it's very interesting indeed

github.comGitHub - WICG/cross-origin-storage: Explainer for the Cross-Origin Storage (COS) APIExplainer for the Cross-Origin Storage (COS) API. Contribute to WICG/cross-origin-storage development by creating an account on GitHub.

Super interesting! Wondering if this could/should live on the browser layer instead of an API layer? E.g. could a browser do the heavy lifting automatically? Like, cached/shared network responses. Not sure how it would decide which files to cache though.

one part that requires bundler integration is that we have to ensure that the chunks are as byte-for-byte identical as possible. e.g. treeshaking, mangled export names, sourcemap comments, etc., need to drop out but then it's over to the browser when we expose the chunks as 'cacheable'

0 reposts5 likes

True! In my head it was as simple as "vue.js version x.y.z always ships as the same js file, with the same cryptographic hash, so it can be reused safely" but it's not that simple. And in any case a website has to dictate which files it actually needs. So maybe it's the right layer haha. Will try!

Thanks for trying! Yes, fullstack frameworks like Nuxt can really help increase the likelihood of cache hits by creating COS-friendly chunks of vendor code that will be the same for all Nuxt users on the same version. That being said, we plan to add support for tapping into COS from just `script`.