A skill for optimizing WebAssembly (Wasm) builds, specifically tailored for game engine adapters. Focuses on binary size reduction, loading performance, and integration with TypeScript/JavaScript.
This skill provides guidelines and tools for optimizing WebAssembly modules used in the project, particularly for game engine adapters (e.g., Stockfish).
.wasm binary size (e.g., using wasm-opt, compiler flags).-O3, , or ?-Oz-Oswasm-opt: Is the binary post-processed with wasm-opt (from Binaryen)?WebAssembly.instantiateStreaming where supported?.wasm file served with Brotli or Gzip compression?// Prefer instantiateStreaming for better performance
async function loadWasm(url: string, importObject: WebAssembly.Imports) {
if (WebAssembly.instantiateStreaming) {
return await WebAssembly.instantiateStreaming(fetch(url), importObject);
} else {
const response = await fetch(url);
const bytes = await response.arrayBuffer();
return await WebAssembly.instantiate(bytes, importObject);
}
}
wasm-opt): Compiler infrastructure and optimization toolchain.unreachable.importObject passed to instantiation matches the imports expected by the Wasm module.