Design system icons often appear dozens of times on one screen, and inline SVG can create a separate subtree per instance. For our monochrome icons, CSS masks removed that markup, simplified updates, and made theming across Shadow DOM easier.
Here's how the approach works, where it scales, and when SVG may still be a better choice.
The problem with inline SVGs
Originally, every one of our icon components resolved to an SVG string. The component parsed the string, cloned an <svg> element, inserted it into its shadow root, and synchronized the node on updates.
That meant every icon on the page carried its own SVG subtree. On icon-heavy screens with lots of menus, tables, toolbars, trees, etc., the same small glyph was parsed, cloned, and stored over and over again.
It also created a fragile update path that produced real bugs, including an update loop and a viewBox regression.
The cost wasn't really about SVG being slow.…