removeViewBox: preserve viewBox for responsive scaling or reduce file size?
0 reputation · 08 Mar 2021, 18:08 UTC
Goal
The objective is to configure the removeViewBox plugin so that SVGs remain responsive in browsers while still achieving the desired file‑size reduction.
Constraints & Uncertainty
SVGs that declare explicit width and height often rely on a viewBox to scale correctly. The plugin removes viewBox by default, but recent releases introduce a preserveViewBox option with values false, true, and auto. The exact default value for auto and how it behaves when width or height are omitted remain ambiguous. Additionally, the relative ordering of removeViewBox and cleanupIDs may influence whether IDs referenced by viewBox-dependent elements survive.
Questions
1. What is the current default value of preserveViewBox in the latest stable svgo release?
2. Does setting preserveViewBox to auto guarantee that viewBox is retained whenever width or height are omitted?
3. How does the ordering of removeViewBox relative to cleanupIDs affect the preservation of IDs that rely on viewBox?