1
0
mirror of https://github.com/svg/svgo.git synced 2026-01-27 07:02:06 +03:00
Files
svgo/docs/04-plugins/reusePaths.mdx
2024-06-16 00:10:42 +01:00

18 lines
1.1 KiB
Plaintext

---
title: reusePaths
svgo:
pluginId: reusePaths
---
Creates a definition for similar paths, and swaps the [`<path>`](https://developer.mozilla.org/docs/Web/SVG/Element/path) elements to [`<use>`](https://developer.mozilla.org/docs/Web/SVG/Element/use) elements that will reference a single `<path>` definition.
It looks for `<path>` elements that have the same [`d`](https://developer.mozilla.org/docs/Web/SVG/Attribute/d), [`fill`](https://developer.mozilla.org/docs/Web/SVG/Attribute/fill), and [`stroke`](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke) attribute values, then copies them into a `<path>` in the [`defs`](https://developer.mozilla.org/docs/Web/SVG/Element/defs) element, creating it if it doesn't exist.
If the path contains other attributes, such as `style` or `transform`, they will be preserved in the `<use>` element that supersedes it.
:::tip
If you only need SVG 2 or inline HTML compatibility, it's recommended to include the [removeXlink](/docs/plugins/removeXlink/) plugin towards the end of your pipeline to convert references to `xlink:href` to the SVG 2 `href` attribute.
:::