---
title: "Experimenting with the proposed Cross-Origin Storage API in Transformers.js"
description: "Browser cache partitioning (in Chrome, keying by Network Isolation Key plus URL) forces every origin running Transformers.js to re-download identical model weights and the ONNX Runtime Wasm file."
url: "https://swe.quest/articles/experimenting-with-the-proposed-cross-origin-storage-api-in-transformers-js-f57157be2f20fb70"
canonical: "https://huggingface.co/blog/cross-origin-storage"
source: "Hugging Face"
published: "2026-06-23"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 13
tags: ["browsers","caching","privacy","inference","javascript"]
---

# Experimenting with the proposed Cross-Origin Storage API in Transformers.js

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-06-23, 13 min read, Deep dive. Original: [https://huggingface.co/blog/cross-origin-storage](https://huggingface.co/blog/cross-origin-storage)

## Summary

Browser cache partitioning (in Chrome, keying by Network Isolation Key plus URL) forces every origin running Transformers.js to re-download identical model weights and the ONNX Runtime Wasm file. In the toy example that duplication costs 177 MB for Whisper alone. The proposed Cross-Origin Storage API (navigator.crossOriginStorage) fixes this by addressing files by SHA-256 hash instead of URL, with an OPFS-like getFileHandle interface. It also verifies hashes on write and lets developers scope visibility via an origins list that can be widened but never narrowed. Privacy is handled through availability gating for rarely seen resources, so apps must treat any error as a cache miss. Transformers.js already ships an experimental opt-in COS backend via env.experimental\_useCrossOriginStorage, testable today with a polyfill extension.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Privacy](https://swe.quest/tags/privacy.md) (Security)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- browser HTTP caching ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- Cache API and OPFS ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- JavaScript async/await ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

Cross-Origin Storage API, Transformers.js, ONNX Runtime Web, Chrome, Network Isolation Key, OPFS, Whisper, WebGPU

## Related posts

- [How to build scalable web apps with OpenAI's Privacy Filter](https://swe.quest/articles/how-to-build-scalable-web-apps-with-openai-s-privacy-filter-e26f0bd30942aaf6.md): Hugging Face · 2026-04-27 · Medium · 6 min read · Privacy, Python, Machine learning, Frontend
  OpenAI's open-source Privacy Filter (1.5B params, 50M active, Apache 2.0) detects PII across eight categories in a single forward pass over 128k tokens.
- [Transformers.js v3: WebGPU Support, New Models & Tasks, and More…](https://swe.quest/articles/transformers-js-v3-webgpu-support-new-models-tasks-and-more-3627acdd60e7ffe6.md): Hugging Face · 2024-10-22 · Medium · 11 min read · Inference & serving, JavaScript, Browsers, Machine learning
  Transformers.js v3 adds WebGPU acceleration via ONNX Runtime Web, claimed up to 100x faster than WASM and enabled by passing \`device: 'webgpu'\` when loading a pipeline.
- [How to Use Transformers.js in a Chrome Extension](https://swe.quest/articles/how-to-use-transformers-js-in-a-chrome-extension-565affa6c1396666.md): Hugging Face · 2026-04-23 · Medium · 8 min read · Browsers, AI agents, Inference & serving, LLMs, JavaScript
  Running local AI in a Chrome Manifest V3 extension works best when the background service worker hosts all Transformers.js models and agent state, while the side panel UI and content scripts act as thin clients over a typed messaging contract.
- [Experimenting with local alt text generation in Firefox Nightly](https://swe.quest/articles/experimenting-with-local-alt-text-generation-in-firefox-nightly-d486bd54cc20de2e.md): Mozilla Hacks · 2024-05-31 · Medium · 9 min read · Inference & serving, Accessibility, Browsers, Computer vision, WebAssembly
  Firefox 130 adds experimental on-device alt text generation for images in the built-in PDF editor, using a 182M-parameter ViT image encoder paired with DistilGPT-2, fine-tuned on COCO, quantized to under 200MB and running in a few seconds on a laptop CPU.
- [Transformers.js v4: Now Available on NPM!](https://swe.quest/articles/transformers-js-v4-now-available-on-npm-60e5d316d3e108bd.md): Hugging Face · 2026-02-09 · Medium · 7 min read · Inference & serving, JavaScript, LLMs, Browsers, Build systems
  Transformers.js v4 ships on NPM with a new C++ WebGPU runtime built with the ONNX Runtime team, enabling WebGPU-accelerated models in browsers as well as Node, Bun and Deno.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
