Binary Sizes
Current local release build sizes (as of the latest build):Baseline Build
File:dist/kimg_wasm_bg.wasm
- Uncompressed: 934 KB
- Gzipped: 346,582 bytes (~338 KB)
SIMD Build
File:dist/kimg_wasm_simd_bg.wasm
- Uncompressed: 1.1 MB
- Gzipped: 385,388 bytes (~376 KB)
simd128 instructions for better performance on supported runtimes.
Size Comparison
| Build Type | Uncompressed | Gzipped | Compression Ratio | |
|---|---|---|---|---|
| Baseline | 934 KB | 338 KB | 36.2% | |
| SIMD | 1.1 MB | 376 KB | 34.2% | |
| Difference | +166 KB | +38 KB |
Context and Comparison
kimg’s binary size is significantly smaller than alternatives:- kimg (baseline): 338 KB gzipped
- kimg (SIMD): 376 KB gzipped
- magick-wasm: 7 MB+ (mentioned in README as a comparison point)
Size Optimization
The build process includes several optimizations:Release Profile
The Rust compiler uses release mode with optimizations:- LTO (Link-Time Optimization)
- Code size optimizations
- Dead code elimination
wasm-opt
The build pipeline runswasm-opt for additional size reduction:
- Removes unused functions
- Optimizes WASM instruction sequences
- Reduces binary bloat
Compression
When serving WASM files:- Always use gzip or brotli compression
- Configure web servers with proper
Content-Encodingheaders - Gzip typically reduces size to ~35% of uncompressed
- Brotli can achieve even better compression ratios
Binary Size Variations
Binary sizes vary slightly based on:- Rust toolchain version - Newer compilers may produce different output
- Optimization settings - Build profile configuration affects size
- Feature flags - Enabled Cargo features change included code
- Dependencies - Upstream crate updates can impact size
Loading Strategy
For optimal user experience:Progressive Enhancement
- Detect SIMD support in the runtime
- Load
kimg_wasm_simd_bg.wasmif supported - Fall back to
kimg_wasm_bg.wasmfor compatibility
Lazy Loading
Load WASM only when needed:Caching
Configure aggressive caching for WASM files:Monitoring Size
Track binary size over time to detect regressions:- Run
./scripts/build.sh - Check
dist/kimg_wasm_bg.wasmsize - Compare against previous builds
- Investigate significant increases