Download once,use everywhere.
Cross-Origin Storage (COS): a content-addressable browser cache
that shares files across origins by hash.
This deck dogfoods Cross-Origin Storage: all fonts, libraries, and AI models load through it.
This browser doesn't support Cross-Origin Storage yet
The slides work anywhere, but the live demos need COS to share files across sites. To see it in action, open this deck with either of these:
π§ͺExperimental Chromium build with native COS
COS extension for Chrome, Firefox, Safari
Cross-Origin StorageWhat do these two games have in common?
They ship the exact same Three.js engine: 734.5 kB of byte-identical JavaScript.
Cross-Origin StorageIt's not just gamesβ¦
Web fonts
Noto Color Emoji on countless sites
Flutter apps
Skia (CanvasKit) in every Flutter web app
Libraries
React, Vue, Angularβ¦, each used on many pages
Wasm
FFmpeg Wasm, SQLite Wasmβ¦, the same builds on many sites
AI runtimes
Transformers.js, WebLLM, wllama, used by different apps
β¦and AI models are big
| Gemma 4 E2B | 3.4 GB |
| Qwen3.5 2B | 1.6 GB |
| Whisper Tiny (English) | 152 MB |
They profit the most from being shared across origins.
Web downloads via Transformers.js (q4f16; Whisper fp32).
Cross-Origin StorageCaches are partitioned β for good reasons
In the good old daysToday, with cache isolation
Shared caches let any site probe what you visited.
A script times β±οΈ how fast a file loads. Near-instant means it was cached, so you've been to a site that uses it.
Cache isolation prevents this.
HTTP cache key β (top-level site, frame site, URL), e.g. Chrome's Network Isolation Key.
Cross-Origin StorageCross-Origin Storage
- Address files by SHA-256 hash, not by URL.
- A new Blob-based store, built on
FileSystemFileHandle. - The writer decides who may read:
- Same-site (default,
'', e.g.quake.exampleβcdn.quake.example) - List of origins (
['https://quake.example', 'https://doom.example']) - Global (
'*')
- Same-site (default,
- Cross-site sharing only for popular files on the Public Hash List (kβanonymity).
- No permission prompts. Designed to work with third-party cookies disabled.
Cross-Origin StorageTwo calls: look up, or store
const hash = {
algorithm: 'SHA-256',
value: '8f4343466β¦dc327aa4',
};
try {
const handle = β¦await navigator.crossOriginStorage
.getFileHandle(hash)β§;
const blob = await handle.getFile();
// Use it. No download!
} catch (err) {
// 'NotFoundError' β Resource not cached
// 'NotAllowedError' β COS not allowed
// Fetch the resource from the network.
}
const hash = {
algorithm: 'SHA-256',
value: '8f4343466β¦dc327aa4',
};
// `blob` holds the bytes, e.g., from `fetch()`.
try {
const handle = await navigator.crossOriginStorage
.getFileHandle(hash, {
create: true,
β¦origins: '*'β§, // or a list of origins
});
const writable = await handle.createWritable();
await writable.write(blob);
await writable.close();
} catch (err) {
// 'DataError' β Bytes don't match the hash
// 'NotAllowedError' β COS not allowed
}
Cross-Origin StorageOr just say it in markup
<script
src="popular-js-framework.js"
integrity="sha256-def456β¦"
β¦crossoriginstorage="*"β§
></script>
@font-face {
font-family: "Popular Emoji Font";
src: url("popular-emoji.woff2"
integrity("sha256-xyz789β¦")
β¦cross-origin-storage(*)β§);
}
import mod from 'popular-module.js' with {
integrity: 'sha256-abc123β¦',
β¦crossOriginStorage: '*'β§,
};
await import('popular-module.js', {
with: { integrity: 'sha256-abc123β¦',
β¦crossOriginStorage: '*'β§ },
});
const response = await fetch('popular-resource.ext', {
integrity: 'sha256-abc123β¦',
β¦crossOriginStorage: '*'β§,
});
Cross-Origin StorageA Vite plugin does the heavy lifting
At build time
vite-plugin-cross-origin-storage splits shared dependencies into chunks named by their SHA-256, so independent builds produce identical bytes.
Runtime loader
For each chunk in the manifest:getFileHandle({ value: hash })
Works as progressive enhancement: without COS, every chunk is a miss.
Hit β
Blob from COS βblob: URL in the import map. Zero bytes over the network.Miss
fetch(file, { integrity }), then store it with origins: '*' for the next site.Developed and maintained by Nuxt
Cross-Origin StorageWithout COS
With COS
AI models
import { pipeline, env } from '@huggingface/transformers';
β¦env.experimental_useCrossOriginStorage = true;β§
const transcriber = await pipeline(
'automatic-speech-recognition', 'onnx-community/whisper-tiny.en');
// Hit: no download. Miss: fetched, then stored in COS for every other site.
Same model, another site
Web fonts
cross-origin-storage(*) Β· on the Public Hash List
@font-face {
font-family: "Doto";
src: url("doto-latin.woff2"
integrity("sha256-HH2fnIb5KftEabipNRCmWTbTvcSeChpoeK4rDz9Hx8I=")
β¦cross-origin-storage(*)β§);
}
/* Hit: no download. Miss: fetched, checked against the hash,
and stored in COS for every other site. */
Same font, another site
βIsn't this a π¦ΈββοΈπͺ supercookie?β
Access is keyed to the top-level site
A tracker iframe that stores a file on site A can't read it back on site B, like any partitioned storage.
Public Hash List
Cross-site sharing only for provably popular files. Everything else acts as absent and throws a NotFoundError.
Small cross-site lookup budget
Per top-level site, lasting weeks and shared by every iframe. Cheaper for large files like models.
Global sharing is opt-in, same-site by default
Sharing with listed origins needs an HTTP header opt-in. Browsers may occasionally lie on purpose.
Cross-Origin StorageWho wants this?
β live
WebLLMMLC AIβ live
wllamallama.cpp for the webβ live
β open CL
Prebid.jsCDN distributionβ live
β live
nuxt-cosβ live
Google FontsWeb fontsβ internal partner
β live
EmscriptenGenerated Wasmβ live
Built against the extension today, ready for a native API tomorrow.
Cross-Origin StorageTry the Cross-Origin Storage API
π§ͺExperimental Chromium build with native COS
Extension for Chrome, Firefox, Safari
Explainer & spec
Cross-Origin StorageEverything this deck loads from COS
Web fonts Β· CSS cross-origin-storage(*) | ||
|---|---|---|
| Roboto (Latin) | 37.5 kB | β |
| Doto (Latin) | 5.4 kB | β |
| Noto Color Emoji, slice 3 | 163.1 kB | β |
| Noto Color Emoji, slice 5 | 121.1 kB | β |
| Noto Color Emoji, slice 6 | 124.6 kB | β |
| Noto Color Emoji, slice 7 | 211.7 kB | β |
| Noto Color Emoji, slice 8 | 423.9 kB | β |
Libraries Β· import() and <script> | ||
| Transformers.js 4.4 (74c0878) | 619.1 kB | β |
| chobitsu 1.8.6 (in-slide DevTools) | 457.9 kB | β |
| qrcode-generator 2.0.4 | 51.9 kB | β |
| browser-fs-access 0.38.0 | 5.9 kB | β |
| Whisper Tiny (English) Β· Transformers.js | ||
|---|---|---|
decoder_model_merged.onnx | 118.6 MB | β |
encoder_model.onnx | 32.9 MB | β |
tokenizer.json | 2.4 MB | β |
tokenizer_config.json | 282.7 kB | β |
config.json | 2.2 kB | β |
generation_config.json | 1.6 kB | β |
preprocessor_config.json | 0.3 kB | β |
| ONNX Runtime Web 1.31 Β· Transformers.js | ||
ort-wasm-simd-threaded.asyncify.wasm | 26.9 MB | β |
ort-wasm-simd-threaded.asyncify.mjs | 53.1 kB | β |
| Three.js r183 Β· the games' Vite plugin | ||
three.core chunk | 378.7 kB | β |
three.module chunk | 355.8 kB | β |
β On the Public Hash List: any site can read it from COS. β Not on the list: only the sites that stored it can.
22 files, 184.0 MB in total. 155.0 MB of it (84%) is on the Public Hash List.
Cross-Origin StorageThank you!Let's talk.
Grab the slides and demos, and run them yourself.