Streaming compilation is preferred for network resources because the engine can begin work before the full response is buffered, provided the server sends `application/wasm`.

Streaming with fallback
const imports = { env: {} };
try {
  const result = await WebAssembly.instantiateStreaming(fetch('/module.wasm'), imports);
  console.log(result.instance.exports);
} catch {
  const bytes = await fetch('/module.wasm').then((res) => res.arrayBuffer());
  const result = await WebAssembly.instantiate(bytes, imports);
  console.log(result.instance.exports);
}
  • Use `ArrayBuffer` or `Uint8Array` for uploads, generated bytes, drag-and-drop files, and fallback paths.
  • Use `Blob` and object URLs for generated downloadable artifacts, then revoke URLs.
  • XMLHttpRequest still works for legacy demos but Fetch is the modern default.