Developer shrinks WebAssembly binary 99.3% from 7MB to 52KB through four rewrites
A developer building a browser-based HTML-to-Markdown converter using WebAssembly faced a major file size problem, as every visitor had to download the .wasm binary on first load. The initial Go implementation weighed around 7MB because Go's WASM output bundles its entire runtime, including a goroutine scheduler and garbage collector. Switching to TinyGo cut the size to roughly 936KB, but library compatibility issues prevented further gains, and a subsequent Rust rewrite using the html5ever-based scraper crate yielded no additional improvement. The breakthrough came when the developer abandoned full DOM-tree parsing entirely and replaced it with a custom single-pass state machine in Rust that required only one dependency, wasm-bindgen. The final binary measured just 52KB, demonstrating that eliminating unnecessary abstractions and dependencies can matter far more than switching programming languages.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in