npm / svgo
svgo
What changed in svgo 2 to 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
2 breaking7 security3 performance1 behavior and defaults11 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initsvgo 421 changes
Breaking changes 2
Invalid XML numeric character references in text and attributes are now rejected; valid XML documents remain unaffected.
Plugin and preset types now enforce that a preset name starts with
preset-.
Security 5
Filters executable data URLs containing HTML, XHTML, or SVG documents and legacy vbscript URLs, while preserving inert data such as PNG images.
Sanitizes SVG foreignObject content by removing HTML event-handler attributes, srcdoc, and executable URLs from specified URL-bearing attributes.
Recognizes namespace-prefixed SVG a elements and removes ASCII tabs and newlines before checking URL schemes, preventing obfuscated script URLs from bypassing detection.
SVGO removeScripts plugin leaves some executable scripts intact
SVGO DoS through entity expansion in DOCTYPE (Billion Laughs)
Performance 3
Speeds up child node removal.
Reduces redundant equality checks.
Computes styles lazily.
Behavior and default changes 1
Plugin listings no longer include whether plugins are enabled or disabled by default; the argument appends each plugin's presets to the end of its line.
Fixes and other changes 10
Parser failures are consistently exposed as SvgoParserError errors with an Invalid character entity reason.
Improves parsing of negative or positive arc radii.
Skips case-normalization for CSS custom properties.
Improves handling of consecutive
tcommands.Handles paths more safely.
Encodes a value as a data URI only once when converting to a data URI.
Logs a warning and does nothing when parameters are missing.
Removes JavaScript URIs case-insensitively and handles <script> elements in a namespace-aware way.
Prevents leftover <use> elements from referencing an empty container that was removed.
Preserves attributes referenced in CSS attribute selectors.
svgo 32 changes
Security 1
Hardens handling of executable data: and vbscript: URLs, executable HTML in <foreignObject>, namespace-prefixed SVG anchors, and URL schemes containing ASCII tabs or newlines.
Fixes and other changes 1
SVGO no longer throws an error when encountering comments in DTD.
svgo 21 changes
Security 1
Hardens removal of script elements by removing known SVG event attributes, rejecting executable data: and vbscript: URLs, sanitizing executable HTML inside foreignObject elements, and handling namespace-prefixed anchors and URL schemes containing ASCII tabs or newlines.