wasmloader
import "github.com/rfwlab/rfw/v2/wasmloader"
WASM loader with progress bar and automatic brotli decompression for Go WASM apps.
Load
func Load(url string, opts Options)
Loads and instantiates a Go WASM bundle. Supports .wasm and .wasm.br (brotli compressed) files.
Options
type Options struct {
Go js.Value // Go runtime instance (required)
Color string // Progress bar color (default: #ff0000)
Height string // Progress bar height (default: 4px)
Blur string // Progress bar blur (default: 8px)
SkipLoader bool // Disable progress bar
}
Behavior
- Tries
.wasm.brfirst, then.wasm
- Shows animated progress bar during load
- Automatically decompresses brotli files
- Calls
Go.run(instance)after instantiation
Example
import "github.com/rfwlab/rfw/v2/wasmloader"
wasmloader.Load("./app.wasm", wasmloader.Options{
Go: js.Global().Get("Go"),
Color: "#00ff00",
})