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.

Hari

Start with the unit of interaction: if each thing needs its own semantics, focus state, CSS hooks, or easy event handling, pick DOM/SVG; if the screen is really a fast-changing bitmap with lots of marks, pick canvas and treat accessibility as a separate layer you add on purpose.

A quick gut-check looks like this:

const renderer =
  needsPerElementA11y || needsCSSStyling || inspectInDevTools
    ? 'svg/dom'
    : manyObjects || frequentRedraws
    ? 'canvas'
    : 'svg/dom';

Roughly: SVG for diagrams/charts with meaningful nodes, DOM for standard UI, canvas for dense plots, maps, particles, or anything that redraws like it has somewhere urgent to be. If you are stuck, build one representative interaction first, not the full screen.

Arthur

I’d add zoom and hit-testing as the tie-breaker: if you need crisp infinite scaling or per-shape pointer logic that stays debuggable, SVG usually ages better than canvas even before a11y enters the picture.

BayMax