{"id":3596,"date":"2026-06-24T14:24:03","date_gmt":"2026-06-24T12:24:03","guid":{"rendered":"https:\/\/blog.tomayac.com\/2026\/06\/24\/guest-blog-post-on-cross-origin-storage-in-transformersjs\/"},"modified":"2026-06-24T14:24:03","modified_gmt":"2026-06-24T12:24:03","slug":"guest-blog-post-on-cross-origin-storage-in-transformers-js","status":"publish","type":"post","link":"https:\/\/tomayac.com\/wordpress\/2026\/06\/24\/guest-blog-post-on-cross-origin-storage-in-transformers-js\/","title":{"rendered":"Guest blog post on Cross-Origin Storage in Transformers.js"},"content":{"rendered":"\n\t\t\t<p>I'm very excited to share a guest post I wrote for the Hugging Face \ud83e\udd17 blog! The post is called \ud83d\udc49\u00a0<a href=\"https:\/\/huggingface.co\/blog\/cross-origin-storage\">Experimenting with the proposed Cross-Origin Storage API in Transformers.js<\/a>\u00a0\ud83d\udc48! This proposed new browser API, <code>navigator.crossOriginStorage.requestFileHandle(hash)<\/code>, has the potential of revolutionizing the Web, a little bit at least. Learn more by reading the <a href=\"https:\/\/github.com\/WICG\/cross-origin-storage\">Explainer for the Cross-Origin Storage (COS) API<\/a>.<\/p>\n<p>And Transformers.js aren't alone with experimenting with this, they're joined by <a href=\"https:\/\/webllm.mlc.ai\/docs\/user\/advanced_usage.html#using-cross-origin-storage-cache\">WebLLM<\/a> (docs), <a href=\"https:\/\/github.com\/ngxson\/wllama\/blob\/master\/src\/storage\/cos.ts\">wllama<\/a> (code), <a href=\"https:\/\/github.com\/flutter\/flutter\/blob\/master\/engine\/src\/flutter\/lib\/web_ui\/flutter_js\/src\/instantiate_wasm.js\">Flutter<\/a> (code), and <a href=\"https:\/\/emscripten.org\/docs\/compiling\/CrossOriginStorage.html#crossoriginstorage\">Emscripten<\/a> (docs).<\/p>\n<p>In a nutshell, this is the usual flow of using the API:<\/p>\n<pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const<\/span> hash <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\n  <span class=\"token literal-property property\">algorithm<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'SHA-256'<\/span><span class=\"token punctuation\">,<\/span>\n  <span class=\"token literal-property property\">value<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4'<\/span><span class=\"token punctuation\">,<\/span>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>\n\n<span class=\"token keyword\">try<\/span> <span class=\"token punctuation\">{<\/span>\n  <span class=\"token keyword\">const<\/span> handle <span class=\"token operator\">=<\/span> <span class=\"token keyword\">await<\/span> navigator<span class=\"token punctuation\">.<\/span>crossOriginStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">requestFileHandle<\/span><span class=\"token punctuation\">(<\/span>hash<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n  <span class=\"token comment\">\/\/ Cache hit! Get the file as a Blob and use it directly.<\/span>\n  <span class=\"token keyword\">const<\/span> fileBlob <span class=\"token operator\">=<\/span> <span class=\"token keyword\">await<\/span> handle<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFile<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n<span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">catch<\/span> <span class=\"token punctuation\">{<\/span>\n  <span class=\"token comment\">\/\/ Cache miss. Download from network, then store for next time.<\/span>\n  <span class=\"token keyword\">const<\/span> fileBlob <span class=\"token operator\">=<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token function\">fetch<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'https:\/\/cdn.jsdelivr.net\/...\/ort-wasm-simd-threaded.asyncify.wasm'<\/span><span class=\"token punctuation\">)<\/span>\n    <span class=\"token punctuation\">.<\/span><span class=\"token function\">then<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">r<\/span> <span class=\"token operator\">=><\/span> r<span class=\"token punctuation\">.<\/span><span class=\"token function\">blob<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n  <span class=\"token keyword\">const<\/span> handle <span class=\"token operator\">=<\/span> <span class=\"token keyword\">await<\/span> navigator<span class=\"token punctuation\">.<\/span>crossOriginStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">requestFileHandle<\/span><span class=\"token punctuation\">(<\/span>\n    hash<span class=\"token punctuation\">,<\/span>\n    <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">create<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token literal-property property\">origins<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'*'<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\n  <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n  <span class=\"token keyword\">const<\/span> writableStream <span class=\"token operator\">=<\/span> <span class=\"token keyword\">await<\/span> handle<span class=\"token punctuation\">.<\/span><span class=\"token function\">createWritable<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n  <span class=\"token keyword\">await<\/span> writableStream<span class=\"token punctuation\">.<\/span><span class=\"token function\">write<\/span><span class=\"token punctuation\">(<\/span>fileBlob<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n  <span class=\"token keyword\">await<\/span> writableStream<span class=\"token punctuation\">.<\/span><span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  \n<span class=\"token punctuation\">}<\/span><\/code><\/pre>\n<p><img src=\"https:\/\/blog.tomayac.com\/images\/cos.svg\" alt=\"The Cross-Origin Storage API logo: a stylized walking person, as typically encountered on crosswalk signs.\" \/><\/p>\n\n\t\t\t<p>\n\t\t\t\t<img alt=\"Thomas Steiner\" width=\"32\" height=\"32\" src=\"https:\/\/blog.tomayac.com\/feed.php?dl=https%3A%2F%2Fblog.tomayac.com%2F2026%2F06%2F24%2Fguest-blog-post-on-cross-origin-storage-in-transformersjs%2F&dp=%2F2026%2F06%2F24%2Fguest-blog-post-on-cross-origin-storage-in-transformersjs%2F&dt=Guest%20blog%20post%20on%20Cross-Origin%20Storage%20in%20Transformers.js\" alt=\"\">\n\t\t\t\t<br\/>This post appeared first on <a href=\"https:\/\/blog.tomayac.com\/2026\/06\/24\/guest-blog-post-on-cross-origin-storage-in-transformersjs\/\">https:\/\/blog.tomayac.com\/2026\/06\/24\/guest-blog-post-on-cross-origin-storage-in-transformersjs\/<\/a>.\n\t\t\t<\/p>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\t\t\tI&#8217;m very excited to share a guest post I wrote for the Hugging Face \ud83e\udd17 blog! The post is called \ud83d\udc49\u00a0Experimenting with the proposed Cross-Origin Storage API in Transformers.js\u00a0\ud83d\udc48! This proposed new browser API, navigator.crossOriginStorage.requestFileH&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"intlwemo_wallet_address":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3596","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3596"}],"version-history":[{"count":1,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3596\/revisions"}],"predecessor-version":[{"id":3597,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3596\/revisions\/3597"}],"wp:attachment":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}