Skip to content

Cleanup Attributes Default

Removes redundant whitespaces from attribute values.

This will not modify the attribute keys, nor remove them if the value becomes empty after optimization.

Usage

js
module.exports = {
  plugins: ["cleanupAttrs"],
};
module.exports = {
  plugins: ["cleanupAttrs"],
};

Parameters

newlinesReplace instances of a newline with a single whitespace.
trimTrim whitespace characters from the start and end of attribute values.
spacesReplace all instances of 2 or more whitespace characters with a single whitespace.
Usage example
js
module.exports = {
  plugins: [
    {
      name: "cleanupAttrs",
      params: {
        newlines: true,
        trim: true,
        spaces: true
      }
    }
  ]
}
module.exports = {
  plugins: [
    {
      name: "cleanupAttrs",
      params: {
        newlines: true,
        trim: true,
        spaces: true
      }
    }
  ]
}

Demo

Implementation

https://github.com/svg/svgo/blob/main/plugins/cleanupAttrs.js