What would you want from a high-level SVG wrapper package?

Another interesting thing one might consider for a higher level wrapper is automatic optimization. What I mean is that SVG gives you nice primitives for geometry, but these are DOM elements and as such quite expensive (I made a relatively simply graphic the other day that produced 8000 DOM nodes (it wasn’t all that complicated either, just lines arranged in a table like structure) and even scrolling the webpage was super sluggish). However, a sufficiently smart library could condense all geometry into a single path element as long as they all shared the same attributes - since diffing and setting the strings in the d attribute is much faster. Or automatically replace stuff with use declarations.

Of course careful benchmarking would be required since you wouldn’t want to spend more time optimizing than the browser rendering.

(Also I suppose one would loose some debug-abillity since the DOM would corespond less to the code one has written. That might be less of concern depending on how high level the library is anyway).

3 Likes