3 ms·
A little D3 war story: I wrote a solver for the Schrödinger equation, which would render a wavefunction with D3 and SVG - cool right. It was very slow to rende
by ridiculous_fish 6y ago
A little D3 war story: I wrote a solver for the Schrödinger equation, which would render a wavefunction with D3 and SVG - cool right.
It was very slow to render. Eventually I found out why: D3 was round-tripping the SVG through text! The render time was dominated by the browser parsing the thousands of 15+ digit floating point numbers.
I added a call to round the floats to two decimal places, so they would be textually shorter, and it was a huge speedup. What a strange optimization.
I later rewrote it using WebGL; here it is should you care: https://ridiculousfish.com/wavefiz/ https://ridiculousfish.com/wavefiz/
- joppy 6y agoI’ve written some animations in React and Svelte recently which edit SVG properties to move objects, and I found myself making the same rounding optimisation (along with using a single path to draw many circles, rather than many circle objects). I think it’s pretty wild that the only way to position objects in the DOM is with strings.