Overview
Editor WASM binaries can be large. You’ll combine compile-time opts (wasm-opt), load strategy (dynamic import()),
and sometimes off-main-thread work for CRDT or
heavy transforms.
Build & ship
- wasm-pack / trunk — common entry points; align with your JS bundler (Vite, Webpack, etc.).
- wasm-opt — shrink and speed; measure before and after for your real workload.
- Source maps — keep for dev; strip for prod when size matters.
Bundle size & splitting
Lazy-load the editor WASM on routes that need it. Consider separating lightweight validation WASM from heavy layout if you truly have two tiers—two modules can be easier to cache than one monolith.
Workers & threads
Moving CRDT merge or parse work to a Web Worker
keeps the main thread responsive. True shared-memory parallelism
needs SharedArrayBuffer, which imposes cross-origin isolation (COOP/COEP) on your site.
Editor UI still needs selection sync on the main thread—workers are not a free pass for input latency; they help CPU-bound background tasks.
Browser constraints
Policies (CSP, COEP, third-party embeds) affect whether you can use threads or import WASM from CDNs. Validate against your deployment target early.
Wasm guides
Editing approaches
contenteditable + WASM: source of truth, event order, DOM↔model loop, normalization, and when to call Rust.
IME & composition
composition events, syncing a Rust document model, and why the browser still owns the IME.
JS ↔ WASM boundary
Strings, copies, batched ops, async vs input events, and keeping the hot path cheap.
Clipboard & input routing
beforeinput, paste, routing decisions in JS vs sanitization in WASM.
Collaboration & CRDT (WASM)
Yrs/y-crdt, bridging to Yjs, snapshots vs update streams with an editor host.
Selection, Range & offsets
UTF-16 vs UTF-8 indices, Selection/Range in JS, mapping to a Rust model and getTargetRanges.
Undo & redo model
Browser undo stack vs model history, programmatic DOM, and WASM-hosted transactions.
Accessibility (WASM host)
Roles, focus, screen readers when the editable surface is still the browser.
Testing & debugging
E2E, profiling the JS↔WASM boundary, reproducing IME and paste in CI.
Security & deployment
CSP, SRI, module integrity, and hosting WASM next to contenteditable.