Image Processing Demo#

Process images in the browser using Go compiled to WebAssembly. This demo compares WASM performance against pure JavaScript.

Loading WASM module...

Select Image

Winter Lake Landscape

Original

Processed

Go WASMJavaScript
Time- ms- ms
Speedup-

How It Works#

This demo uses gowasm-bindgen to generate TypeScript bindings for Go image processing functions compiled with TinyGo:

// Go code compiled to WASM with TinyGo
func Sharpen(pixels []byte, width, height, strength int) []byte {
    result := make([]byte, len(pixels))
    center := 1 + 4*strength
    edge := -strength

    for y := 0; y < height; y++ {
        for x := 0; x < width; x++ {
            // 5-point convolution kernel
            // ...
        }
    }
    return result
}

The same algorithms are implemented in JavaScript for comparison. Modern JS engines are highly optimized, so performance is roughly comparable for these compute-intensive tasks.

Why Go WASM?#

The real value of Go-to-WASM isn’t raw speed - modern JavaScript engines are excellent. The benefits are:

  • Code reuse - Share validation, parsing, or business logic between server and browser
  • Type safety - Go’s type system catches errors at compile time
  • Existing libraries - Use Go packages directly in the browser
  • Predictable performance - No JIT warmup or garbage collection pauses

Source Code#