Skip to content

Add size-optimized WASM build using -Oz flag#52

Merged
simonw merged 1 commit intomainfrom
claude/optimize-wasm-size-lRcu5
Dec 24, 2025
Merged

Add size-optimized WASM build using -Oz flag#52
simonw merged 1 commit intomainfrom
claude/optimize-wasm-size-lRcu5

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Dec 24, 2025

Tip from azakai on Hacker News: https://news.ycombinator.com/context?id=46370980

Looks like those sizes could be improved significantly, as the builds include names etc. I would suggest linking with

emcc -O3

(and maybe even adding --closure 1 )

- Created build_wasm_optimized.py that builds with -Oz optimization
- Achieves 35% size reduction: 229KB → 148KB
- Note: -O3 actually increases size (to 248KB) due to aggressive inlining
- Verified optimized build passes all functional tests
- Updated README.md and notes.md with optimization findings
@simonw
Copy link
Owner Author

simonw commented Dec 24, 2025

I prompted:

Try optimizing the size of the WASM file in this repo that was was used for https://tools.simonwillison.net/microquickjs - use this:
emcc -O3
If it works add it to the existing research report about this with a file name that has _optimized.wasm

–closure 1 might work too? We are looking to optimize the wasm bundle size while keeping it working

@simonw simonw merged commit e237587 into main Dec 24, 2025
@simonw simonw deleted the claude/optimize-wasm-size-lRcu5 branch December 24, 2025 01:17
simonw added a commit to simonw/tools that referenced this pull request Dec 24, 2025
* Add optimized MicroQuickJS WASM and version selector

- Add mquickjs_optimized.js and mquickjs_optimized.wasm (148 KB vs 223 KB)
- Add WASM version selector dropdown defaulting to optimized build
- Version persists via URL parameter (?wasm=original for non-optimized)
- Both versions tested with playwright-python and work correctly

* Add playwright test script for microquickjs.html

Tests both optimized and original WASM versions with 6 test cases
covering basic operations, functions, JSON, arrays, and strings.

Refs: simonw/research#52

---------

Co-authored-by: Claude <noreply@anthropic.com>

### WASM Size Optimization

**Date**: 2024-12-24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 2025-12-24?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants