Back to Svgo

addClassesToSVGElement

docs/04-plugins/addClassesToSVGElement.mdx

4.0.1659 B
Original Source

Overrides the class attribute in the outer most <svg> element, omitting duplicates or null classes if found in your configuration.

:::caution

If there is no class attribute to begin with, it will be added. However, if the there were already classes assigned, these are removed and replaced with the classes configured in this plugin.

:::

If you have a standalone SVG, this is not an optimization and will increase the size of the SVG document. This plugin is only relevant when considering multiple SVGs that may be inlined a parent document.

By adding classes, if the parent document is aware, you can share styles across all inlined SVG elements.