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.

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
  • Go 1.25 or later
  • make (GNU Make)

Run the following from the repository root:

Terminal window
make build-wasm

This produces two artifacts:

FileDescription
gh-aw.wasmThe compiled WebAssembly module (~17 MB uncompressed)
$(go env GOROOT)/misc/wasm/wasm_exec.jsGo’s Wasm runtime (ships with your Go installation)

Copy both files to your project:

Terminal window
cp gh-aw.wasm your-project/
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" your-project/

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.

Terminal window
# 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.

<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>