mirror of
https://github.com/svg/svgo.git
synced 2026-01-27 07:02:06 +03:00
SVGs can have the same presentation attribute declared redundantly in both the node attributes and `<style>` tag. This wouldn't break anything, but we can shave off a few more bytes by dropping the attribute in this case.
41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
---
|
|
title: Remove Empty Text
|
|
svgo:
|
|
pluginId: removeEmptyText
|
|
defaultPlugin: true
|
|
parameters:
|
|
text:
|
|
description: If to remove empty <a href="https://developer.mozilla.org/docs/Web/SVG/Element/text" target="_blank"><code><text></code></a> elements.
|
|
default: true
|
|
tspan:
|
|
description: If to remove empty <a href="https://developer.mozilla.org/docs/Web/SVG/Element/tspan" target="_blank"><code><tspan></code></a> elements.
|
|
default: true
|
|
tref:
|
|
description: If to remove empty <a href="https://developer.mozilla.org/docs/Web/SVG/Element/tref" target="_blank"><code><tref></code></a> elements.
|
|
default: true
|
|
---
|
|
|
|
Removes empty [`<text>`](https://developer.mozilla.org/docs/Web/SVG/Element/text) and [`<tspan>`](https://developer.mozilla.org/docs/Web/SVG/Element/tspan) elements, and [`<tref>`](https://developer.mozilla.org/docs/Web/SVG/Element/tref) elements that don't reference another node in the document.
|
|
|
|
:::info
|
|
|
|
No browsers supports `<tref>`, so it's best to avoid that element regardless.
|
|
|
|
:::
|
|
|
|
## Usage
|
|
|
|
<PluginUsage/>
|
|
|
|
### Parameters
|
|
|
|
<PluginParams/>
|
|
|
|
## Demo
|
|
|
|
<PluginDemo/>
|
|
|
|
## Implementation
|
|
|
|
* https://github.com/svg/svgo/blob/main/plugins/removeEmptyText.js
|