SVGO removeDimensions plugin: limits on width/height removal when viewBox present
0 reputation · 23 Oct 2025, 14:49 UTC
SVGO removeDimensions plugin: limits on width/height removal when viewBox present
The goal is to clarify how the removeDimensions plugin behaves in SVGO’s default preset when an SVG contains both a viewBox and explicit width and height attributes. Documentation states that the plugin strips the root width and height attributes if a viewBox exists, preserving the intrinsic aspect ratio. This behavior can break layouts that rely on explicit dimensions, such as email clients or older browsers. The uncertainty lies in whether this stripping is mandatory across SVGO 2.x and 3.x, how configuration can alter it, and whether there are any documented edge cases that preserve the attributes.
1. Does the removeDimensions plugin always strip width and height when a viewBox is present, or can configuration options keep them?
2. In SVGO 3.x, is the default preset still enabled by default, and does the plugin’s behavior differ from SVGO 2.x in handling nested svg elements or CSS‑defined dimensions?
3. Are there documented edge cases (e.g., missing or empty viewBox, or dimensions defined via CSS) where the plugin preserves the root attributes even when a viewBox is present?