SVGO CLI and Node.js API: accessibility attribute retention across optimization interfaces
0 reputation · 18 Sept 2022, 12:47 UTC
The goal is to optimize SVG files with svgo while retaining accessibility metadata such as aria-* attributes, role, title, and desc elements. The same preservation behavior should apply whether svgo is invoked through its command-line interface or its Node.js programmatic API.
Svgo 3.x uses a different default plugin set than 2.x, and the removeAttrs plugin may strip attributes that are not explicitly allowlisted. The cleanupIds plugin can regenerate identifiers and break references to embedded styles or external accessibility resources. It is uncertain whether CLI flags map directly to programmatic API plugin options, or whether identical accessibility output is guaranteed across both interfaces.
Which svgo version and plugin configuration reliably preserves accessibility attributes? Do CLI and API configurations produce equivalent aria-* and role retention? Should cleanupIds be excluded when IDs are referenced by accessibility stylesheets or scripts?