WebAssembly Compilation
The gh-aw compiler can be built as a WebAssembly (Wasm) module, letting you compile agentic workflows directly in the browser without a server-side Go installation.
Overview
Section titled “Overview”The Wasm build packages the core compilation engine — markdown parsing, frontmatter extraction, import resolution, and YAML generation — into a single .wasm file. You load it with Go’s standard wasm_exec.js runtime, then call a global compileWorkflow() function from JavaScript.
This is useful for:
- Interactive playgrounds where users experiment with workflow syntax
- Editor integrations that preview compiled YAML in real time
- Offline tools that need compilation without a backend
Prerequisites
Section titled “Prerequisites”- Go 1.25 or later
make(GNU Make)
Building
Section titled “Building”Run the following from the repository root:
make build-wasmThis produces two artifacts:
| File | Description |
|---|---|
gh-aw.wasm | The compiled WebAssembly module (~17 MB uncompressed) |
$(go env GOROOT)/misc/wasm/wasm_exec.js | Go’s Wasm runtime (ships with your Go installation) |
Copy both files to your project:
cp gh-aw.wasm your-project/cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" your-project/Compression
Section titled “Compression”The raw .wasm binary is ~17 MB. The build pipeline pre-compresses it with brotli at maximum quality (-q 11), producing a gh-aw.wasm.br file of ~5 MB — a ~70% reduction. GitHub Pages serves the .br file automatically when the browser sends Accept-Encoding: br.
# Manual compression (if not using the bundle script)brotli -k -q 11 gh-aw.wasm # produces gh-aw.wasm.br (~5 MB)The docs site bundle script (scripts/bundle-wasm-docs.sh) handles this automatically. If brotli is not installed, it falls back to gzip (-9), which achieves ~6 MB.
JavaScript API
Section titled “JavaScript API”Loading the module
Section titled “Loading the module”<script src="wasm_exec.js"></script><script>const go = new Go();WebAssembly.instantiateStreaming( fetch("gh-aw.wasm"), go.importObject).then((result) => { go.run(result.instance); // compileWorkflow is now available globally});</script>