What SVG Optimization Removes
SVG files exported from design tools (Illustrator, Figma, Inkscape) typically contain significant overhead: XML comments, editor-specific namespaces, unused <defs> blocks, empty elements, redundant group wrappers, and verbose attribute formatting. None of this affects how the SVG renders in a browser.
Common removals:
- XML declarations (
<?xml version="1.0"?>)
<!-- comments -->
- Inkscape/Sodipodi/Adobe namespaces and metadata elements (
<metadata>, <sodipodi:*>, <inkscape:*>)
- Empty
<g> groups with no meaningful attributes
id attributes not referenced elsewhere
- Default attribute values (e.g.,
fill-opacity="1", stroke="none")
- Unnecessary whitespace inside path
d attributes and between elements
When Not to Optimize Aggressively
Aggressive optimization can cause problems in specific cases:
- SVGs used with CSS selectors targeting specific IDs or classes — removing IDs breaks the selector
- SVGs embedded in animation libraries that reference element IDs
- Technical diagrams where sub-pixel coordinate precision matters
- SVGs with
<title> used for accessibility (screen readers)
Use Gentle or Balanced for SVGs that are part of interactive or accessible UI.