Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Pract...
Search
petamoriken / 森建
May 07, 2026
Programming
120
2
Share
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
fukuoka.ts #4
https://fukuoka-ts.connpass.com/event/387858/
petamoriken / 森建
May 07, 2026
More Decks by petamoriken / 森建
See All by petamoriken / 森建
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
240
Module Harmony
petamoriken
3
940
Denoでフロントエンド開発 2025年春版 / Frontend Development with Deno (Spring 2025)
petamoriken
1
1.6k
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
640
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
320
フロントエンドの標準仕様をどう追っているか / How I follow the frontend standards specs
petamoriken
4
2.7k
ECMAScript、Web標準の型はどう管理されているか / How ECMAScript and Web standards types are maintained
petamoriken
3
650
DOM Observable
petamoriken
1
350
Deno に Web 標準 API を実装する / Implementing Web standards API to Deno
petamoriken
0
810
Other Decks in Programming
See All in Programming
AI-DLC Deep Dive
yuukiyo
9
4.9k
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
230
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
990
t *testing.T は どこからやってくるの?
otakakot
1
800
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
190
瑠璃の宝石に学ぶ技術の声の聴き方 / 【劇場版】アニメから得た学びを発表会2026 #エンジニアニメ
mazrean
0
300
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
880
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
600
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
290
Road to RubyKaigi: Play Hard(ware)
makicamel
1
490
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
150
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
24
15k
Featured
See All Featured
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
330
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
First, design no harm
axbom
PRO
2
1.2k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Ethics towards AI in product and experience design
skipperchong
2
260
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Ruling the World: When Life Gets Gamed
codingconduct
0
220
New Earth Scene 8
popppiees
3
2.1k
How to build a perfect <img>
jonoalderson
1
5.4k
Deep Space Network (abreviated)
tonyrice
0
130
Docker and Python
trallard
47
3.8k
Google's AI Overviews - The New Search
badams
0
990
Transcript
WebAssembly を読み込む ベストプラクティス 2026 年春版 fukuoka.ts #4 pixiv Inc. 森内建太 @petamoriken 2026.5.7
2 自己紹介 • Web エンジニア • Deno / ECMAScript コントリビューター • フロントエンドカンファレンス福岡スピーカー • Web 標準 を追うのが好き
petamoriken WebDev in Fukuoka
3 https://scrapbox.io/petamoriken/
背景 4
5 • W3C ワーキンググループが策定しているバイトコード • C/C++, Rust, AssemblyScript などからコンパイル ◦ C/C++ は Emscripten を使ってコンパイルする •
ほとんどの JS エンジン上で実行できる ◦ Chrome, Firefox, Safari, Ladybird ◦ Deno, Node.js, Bun, Cloudflare Workers WebAssembly
6 • 洞窟物語 Pixel さんが作った独自音楽形式 “pxtone” を ブラウザでデコード、再生するライブラリ • 10年前に Pixel さんにメールで頼み込んで C++ ソース コードをもらい、Emscripten をつかってコンパイル PxtoneJS
7 • Emscripten の出力サイズがとにかくでかい ◦ Emscripten に依存せずに Wasm 化する方法を模索 👉 Wasm 化できる標準 C++ ライブラリがなさそう • いっそのこと C++ を Rust にポートしよう 👉
挫折 PxtoneJS v3 (2017-02)
8 • 2026-02 Ladybird が LibJS を C++ から Rust へポート ◦ AI Agent を使えば Rust 化できるのでは?
9 • GW に Claude Code を使って Rust にポートできた! ◦ コンパイル後約 60% の容量削減 • ついでにストリーム再生 API を追加 ◦ Web 標準仕様にストリーム再生用の API がなかった ◦
今は WebCodecs の AudioData がいい感じ PxtoneJS v4 (2026-05)
WebAssembly の読み込み 10
11 WebAssembly の読み込み ArrayBuffer WebAssembly.Module WebAssembly.Instance const url = import.meta.resolve("./foo.wasm"); const
response = await fetch(url); const buffer = await response.arrayBuffer(); const module = new WebAssembly.Module(buffer); const instance = new WebAssembly.Instance(module); const { foo } = instance.exports;
12 WebAssembly の読み込み ArrayBuffer WebAssembly.Module WebAssembly.Instance const url = import.meta.resolve("./foo.wasm"); const
response = await fetch(url); const buffer = await response.arrayBuffer(); const module = new WebAssembly.Module(buffer); const instance = new WebAssembly.Instance(module); const { foo } = instance.exports; モジュールの依存に入らない(要バンドラー設定)
13 WebAssembly の読み込み ArrayBuffer WebAssembly.Module WebAssembly.Instance const url = import.meta.resolve("./foo.wasm"); const
response = await fetch(url); const buffer = await response.arrayBuffer(); const module = new WebAssembly.Module(buffer); const instance = new WebAssembly.Instance(module); const { foo } = instance.exports; Top-level await で非同期モジュールが強制される
14 WebAssembly の読み込み ArrayBuffer WebAssembly.Module WebAssembly.Instance const base64 = "AGFzbQEAAAABkAEVYAJ/fwF/YAJ..."; const
{ buffer } = Uint8Array.fromBase64(base64); const module = new WebAssembly.Module(buffer); const instance = new WebAssembly.Instance(module); const { foo } = instance.exports;
15 WebAssembly の読み込み ArrayBuffer WebAssembly.Module WebAssembly.Instance const base64 = "AGFzbQEAAAABkAEVYAJ/fwF/YAJ..."; const
{ buffer } = Uint8Array.fromBase64(base64); const module = new WebAssembly.Module(buffer); const instance = new WebAssembly.Instance(module); const { foo } = instance.exports; Base64 文字列で無理矢理インライン化して解決
16 WebAssembly の読み込み Stage 2.7 Import Bytes (Deno, Node.js, Bun サポート) ArrayBuffer
WebAssembly.Module WebAssembly.Instance import buffer from "./foo.wasm" with { type: "bytes", }; const module = new WebAssembly.Module(buffer); const instance = new WebAssembly.Instance(module); const { foo } = instance.exports;
17 WebAssembly の読み込み Stage 3 Source Phase Imports (Deno, Node.js, Cloudflare
Workers サポート) ArrayBuffer WebAssembly.Module WebAssembly.Instance import source module from "./foo.wasm"; const instance = new WebAssembly.Instance(module); const { foo } = instance.exports;
18 WebAssembly の読み込み Phase 3 ES Module Integration for WebAssembly (Deno,
Node.js サポート) ArrayBuffer WebAssembly.Module WebAssembly.Instance import { foo } from "./foo.wasm";
19 • AI Agent で C/C++ を Rust にポートするのが容易に ◦ ライセンスに注意 • ストリーム再生は WebCodecs の AudioData が便利 • WebAssembly を使ったライブラリを配布する場合、
現状 Base64 文字列でインライン化するのがよさそう ◦ 将来的に解決される予定 まとめ