removeDesc
Default
Removes the <desc>
element from the document in one of the following conditions:
- The
<desc>
element is empty. - The
<desc>
element appears to only contain editor attribution.
This plugin does not remove the <desc>
indiscriminately by default, as it is a crucial aspect of accessibility for users of assistive technologies.
Usage
- Basic
- Parameters
svgo.config.js
module.exports = {
plugins: [
"removeDesc"
]
}
svgo.config.js
module.exports = {
plugins: [
{
name: "removeDesc",
params: {
removeAny: false
}
}
]
}
Parameters
removeAny
By default, this plugin only removes descriptions that are either empty or contain editor attribution. Enabling this removes the
<desc>
element indiscriminately.
Demo
Live Editor
const svg = ` <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox=" 0 0 150 100 " width="150"> <!-- Created with love! --> <defs> <ellipse cx="50" cy="50.0" rx="50.00" ry="auto" fill="black" id="circle"/> </defs> <g> <use href="#circle" transform="skewX(16)"/> <rect id="useless" width="0" height="0" fill="#ff0000"/> </g> </svg> `; const svgoConfig = { js2svg: { indent: 2, pretty: true }, plugins: [ "removeDesc" ] } render(<SvgoPreview svg={svg} svgoConfig={svgoConfig}/>);
Result
Loading...