Optimize the size or speed of a WebAssembly binary file using the wasm-opt command-line tool.
Integrate Binaryen as a C++ library inside a new compiler or language that targets WebAssembly.
Convert a WebAssembly module back to JavaScript using wasm2js for environments that do not support WebAssembly natively.
Building from source requires a C++ toolchain, using the pre-built wasm-opt binary is much faster to get started.
Binaryen is a C++ library that helps other tools compile code to WebAssembly. WebAssembly is a low-level format that runs in web browsers and other environments at near-native speed, and Binaryen handles the difficult work of converting code into that format and then optimizing it for size and performance. Most developers will not use Binaryen directly. Instead, it works as an internal component inside tools they may already know. When you compile C or C++ for the browser using Emscripten, Binaryen produces the final WebAssembly output. When you compile Rust using wasm-pack, Binaryen runs in the background. Kotlin, Dart, and OCaml also route their WebAssembly output through Binaryen. The main command-line tool it ships is called wasm-opt, which reads a WebAssembly file, applies optimization passes, and writes a smaller or faster result. Binaryen also supports languages that compile directly to WebAssembly using it as a library, such as AssemblyScript (a TypeScript-like language designed for WebAssembly). It includes an interpreter for running and testing WebAssembly code, and a converter called wasm2js that turns WebAssembly modules back into JavaScript for environments without native WebAssembly support. Internally, Binaryen represents code as a tree structure rather than the stack-based format WebAssembly uses at the binary level. This tree representation makes it easier to apply many optimization passes, such as dead code removal, function inlining, and WebAssembly-specific size reduction analogous to how JavaScript minifiers work. The full README is longer than what was shown.
← webassembly on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.