Skip to main content
InterviewHubPRO
Section Overview
Q31

Question 31 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

62%
HTML5 & Web APIs (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Canvas (`<canvas>`) vs. SVG (`<svg>`): Performance and Architectural Trade-Offs.

senior LevelFormsPerformanceSystem Design

In Simple Words:

  • SVG (Scalable Vector Graphics):
    • Vector-based XML DOM elements. Infinitely sharp scaling.
    • Each shape (<circle>, <path>) is an individual node in the browser DOM.
    • Bottleneck: Having $> 5,000$ SVG DOM nodes causes severe layout thrashing and DOM memory bloat.
    • Best for: Icons, charts, logos, user interfaces.
  • Canvas (<canvas>):
    • Immediate-mode bitmap pixel surface rendered via JavaScript 2D context or WebGL.
    • The browser sees only a single DOM element (<canvas>).
    • Best for: High-performance games, 100,000 data points scatterplots, real-time video manipulation.