svgo
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@trysound/sax | 0.2.0 | 13.22 kB | ISC | prod | |
commander | 7.2.0 | 37.27 kB | MIT | prod | |
css-select | 5.1.0 | 33.52 kB | BSD-2-Clause | prod | |
css-tree | 2.3.1 | 272.24 kB | MIT | prod | 1 |
csso | 5.0.5 | 164.22 kB | MIT | prod | 1 |
picocolors | 1.0.0 | 2.35 kB | ISC | prod |
SVGO, or SVG Optimizer, is a Node.js-based tool designed to optimize SVG (Scalable Vector Graphics) files. SVG files, often exported from various editors, can contain redundant and unnecessary information such as editor metadata, comments, hidden elements, non-optimal values, and more. SVGO is capable of removing or converting this extraneous information without affecting the SVG file's rendering result, thereby optimizing the file for better performance.
To start using SVGO, it has to be installed via npm or yarn. You can install it globally on your system using the following commands:
Using npm:
npm -g install svgo
Or using yarn:
yarn global add svgo
For processing individual files, use the svgo
command followed by the filenames:
svgo one.svg two.svg -o one.min.svg two.min.svg
For processing a directory of SVG files recursively, use the -f
or --folder
option:
svgo -f ./path/to/folder/with/svg/files -o ./path/to/folder/with/svg/output
Execution options can be viewed using the --help
command:
svgo --help
SVGO also offers various configurations through a plugin-based architecture. You can create a svgo.config.js
file or specify a path to your configuration file using the --config ./path/myconfig.js
command. Here is an example of a possible configuration:
// svgo.config.js
module.exports = {
multipass: true, // boolean. false by default
datauri: 'enc', // 'base64' (default), 'enc' or 'unenc'.
js2svg: {
indent: 2, // string with spaces or number of spaces. 4 by default
pretty: true, // boolean, false by default
},
plugins: [
'preset-default',
'prefixIds',
{
name: 'sortAttrs',
params: {
xmlnsOrder: 'alphabetical',
},
},
],
};
The complete documentation of SVGO including detailed usage and configuration guidelines, as well as the description of all built-in plugins, can be found on the SVGO GitHub repository: github.com/svg/svgo. The repository provides comprehensive information and examples to help you get the most out of the SVG Optimizer tool.