SVGO Use
SVGO is a CLI tool to compress SVG’s. If you’ve just created an SVG from an app like Illustrator for example, using SVGO will reduce the file size by getting rid of extraneous code.
It’s a mature tool that’s regularly updated and can be installed with npm: npm -i svgo.
For simple use just use svgo path/to/my.svg. This will compress that file.
If you want to be able to read and presumably edit your svg in a code editor afterwards then add the --pretty option.
1svgo my.svg --pretty
And if you want to output the file to a different folder use the output -o flag and the path to the folder:
1svgo my.svg -o path/to/folder --pretty
This creates a new version of the file in that folder in a human readable format.
Official Help
This is from the help file (svgo --help)
Usage: svgo [options] [INPUT…]
Nodejs-based tool for optimizing SVG vector graphics files
Arguments: INPUT Alias to –input
Options:
| flag added to svgo | function |
|---|---|
| -v, –version | output the version number |
| -i, –input <INPUT…> | Input files, “-” for STDIN |
| -s, –string | Input SVG data string |
| -f, –folder | Input folder, optimize and rewrite all *.svg files |
| -o, –output <OUTPUT…> | Output file or folder (by default the same as the input), “-” for STDOUT |
| -p, –precision | Set number of digits in the fractional part, overrides plugins params |
| –config | Custom config file, only .js is supported |
| –datauri | Output as Data URI string (base64), URI encoded (enc) or unencoded (unenc) |
| –multipass | Pass over SVGs multiple times to ensure all optimizations are applied |
| –pretty | Make SVG pretty printed |
| –indent | Indent number when pretty printing SVGs |
| -r, –recursive | Use with ‘–folder’. Optimizes *.svg files in folders recursively. |
| –exclude <PATTERN…> | Use with ‘–folder’. Exclude files matching regular expression pattern. |
| -q, –quiet | Only output error messages, not regular status messages |
| –show-plugins | Show available plugins and exit |
| -h, –help | display help for command |