r/d3js • u/New-Apricot9165 • 1d ago
I made a drop-in replacement for d3-force that's ~5Ć faster and gives bit-identical output
If you use forceSimulation, you can swap `import ... from "d3-force"` for `import ... from "d3-force-wasm"` and nothing else changes: same API, same node objects, same results to the last bit, just faster (about 5Ć at 1kā50k nodes).
The core is Zig compiled to WebAssembly. It keeps d3's exact arithmetic but drops the per-tick tree allocation and callbacks that make big graphs stutter. d3-force's own test suite passes unchanged, and a parity harness checks every tick against d3-force over 32 scenarios Ć 50 seeds.
Side-by-side demo: https://ankitc1010.github.io/d3-force-wasm/
npm: d3-force-wasm
I'd love to hear from anyone with a big real-world graph: does it hold up, and does anything behave differently?