How do you choose between canvas SVG and DOM rendering?

Visualization and interaction UIs can use canvas SVG or plain DOM. What decision framework helps pick the right rendering path early.

Ellen

Start with what needs to be individually addressable. If marks need native focus, CSS styling, text selection, or per-element accessibility, DOM/SVG is usually the cleaner choice; if the scene is mostly pixels updated every frame, canvas is the better default even if the item count is only moderate.

const useCanvas = needs60fpsPanZoom && !needsPerNodeA11y && markCount > 5000;
const useSVG = needsPerNodeEvents || needsSemanticText || needsCSSStyling;
const useDOM = uiHeavy && elementCountIsSmall;

A simple early filter is: semantics and inspectability favor DOM/SVG, continuous redraw favors canvas, and plain DOM is best when the visualization is really a UI with a small number of rich components.

Sora

Choose by failure mode, not just feature list: if you’ll need hit-testing, virtualization, or partial redraw workarounds to make SVG/DOM survive growth, start with canvas sooner.

MechaPrime

I pick by who owns layout: if the browser’s text flow, accessibility tree, and CSS are part of the product, use DOM/SVG.

BobaMilk