What Optimize keeps
Optimize is off by default on the React converter. When you turn it on, the file is sanitized, then SVGO runs preset-default with multipass: true, then the sanitizer runs again. The SVG optimizer page always uses that same preset. Neither place enables the currentColor plugin. Colors may still be shortened, which is a different edit.
What stays
On the preset this site runs, these parts of a normal icon stay:
viewBox. The preset does not includeremoveViewBox. A viewBox of0 0 24 24is still0 0 24 24after Optimize.- Root
widthandheight.removeDimensionsis not part of the preset, so a 24 by 24 icon keeps those attributes. xmlns.removeXMLNSis not part of the preset.- A
<title>element. There is noremoveTitleplugin in the preset. - A
<desc>whose text is a real description, such as "Points right". Empty descriptions are removed, and a description that starts with "Created with" or "Created using" is removed because that is editor boilerplate. The preset does not setremoveAny, so it does not delete every description. - A gradient that something in the file still paints with. The id may be shortened, and the
url(#...)reference in the same file is updated to match. fill="none"staysnone. A rounded rectangle, one withrxorry, stays arect.
What changes or goes away
The same preset removes or rewrites other things. These are the visible ones:
- The XML declaration, comments, and
<metadata>. An Inkscape or Illustrator namespace, and attributes in those namespaces, are editor data and are removed. - A
<linearGradient>that nothing references. fill="black"on a shape, because black is the SVG default. The shape is still filled black. A hex such as#ffffffcan become#fff, and#ff00aacan become#f0a. That is color shortening, notcurrentColor.- A rectangle without rounded corners can become a
<path>. Path data can be rewritten to a shorter equivalent command. Groups that do nothing can be collapsed. - Ids that exist only so the file can point at them can be shortened (
id="bg"may becomeid="a"). References inside the file are updated. A stylesheet or a script outside the file that targeted the old id will not find it.
What Optimize does not replace
Optimize does not remove <script> by itself as its job. The sanitizer already removed scripts, event handlers, foreignObject, and unsafe URLs before SVGO runs, and it checks the SVGO output again. If that second sanitize fails, the optimizer reports the error and does not offer the raw input as the download. See What the sanitizer removes.
Optimize does not rewrite class to className. That happens later, when SVGR prints JSX or TSX. With Optimize left off, metadata and comments are still in the component, which is an easy way to see that the preset did not run.
Turning on currentColor at the same time is a separate plugin, documented in What currentColor changes. It can flatten a gradient and then let this preset delete the unused gradient. Leave currentColor off if the gradient is the artwork.