Gathering detailed insights and metrics for svgo
Gathering detailed insights and metrics for svgo
Gathering detailed insights and metrics for svgo
Gathering detailed insights and metrics for svgo
npm install svgo
Typescript
Module System
Min. Node Version
62.7
Supply Chain
99.6
Quality
84.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
3,836,266,345
Last Day
3,428,960
Last Week
17,944,314
Last Month
78,476,284
Last Year
875,564,437
21,112 Stars
1,537 Commits
1,391 Forks
242 Watching
5 Branches
203 Contributors
Minified
Minified + Gzipped
Latest Version
3.3.2
Package Id
svgo@3.3.2
Unpacked Size
1.42 MB
Size
357.05 kB
File Count
79
Publised On
09 May 2024
Cumulative downloads
Total Downloads
Last day
-0.8%
3,428,960
Compared to previous day
Last week
5.9%
17,944,314
Compared to previous week
Last month
5%
78,476,284
Compared to previous month
Last year
5.2%
875,564,437
Compared to previous year
SVGO, short for SVG Optimizer, is a Node.js library and command-line application for optimizing SVG files.
SVG files, especially those exported from vector editors, usually contain a lot of redundant information. This includes editor metadata, comments, hidden elements, default or suboptimal values, and other stuff that can be safely removed or converted without impacting rendering.
You can install SVGO globally through npm, yarn, or pnpm. Alternatively, drop the global flag (global
/-g
) to use it in your Node.js project.
1# npm 2npm install -g svgo 3 4# yarn 5yarn global add svgo 6 7# pnpm 8pnpm add -g svgo
Process single files:
1svgo one.svg two.svg -o one.min.svg two.min.svg
Process a directory of files recursively with -r
/--recursive
and -f
/--folder
:
1svgo -rf path/to/directory_with_svgs -o path/to/output_directory
Help for advanced usage:
1svgo --help
SVGO has a plugin architecture. You can read more about all plugins in Plugins | SVGO Documentation, and the default plugins in Preset Default | SVGO Documentation.
SVGO reads the configuration from svgo.config.mjs
or the --config path/to/config.mjs
command-line option. Some other parameters can be configured though command-line options too.
svgo.config.mjs
1export default { 2 multipass: false, // boolean 3 datauri: 'base64', // 'base64'|'enc'|'unenc' 4 js2svg: { 5 indent: 4, // number 6 pretty: false, // boolean 7 }, 8 plugins: [ 9 'preset-default', // built-in plugins enabled by default 10 'prefixIds', // enable built-in plugins by name 11 12 // enable built-in plugins with an object to configure plugins 13 { 14 name: 'prefixIds', 15 params: { 16 prefix: 'uwu', 17 }, 18 }, 19 ], 20};
Instead of configuring SVGO from scratch, you can tweak the default preset to suit your needs by configuring or disabling the respective plugin.
svgo.config.mjs
1export default { 2 plugins: [ 3 { 4 name: 'preset-default', 5 params: { 6 overrides: { 7 // disable a default plugin 8 cleanupIds: false, 9 10 // customize the params of a default plugin 11 inlineStyles: { 12 onlyMatchedOnce: false, 13 }, 14 }, 15 }, 16 }, 17 ], 18};
You can find a list of the default plugins in the order they run in Preset Default | SVGO Documentation.
You can also specify custom plugins:
svgo.config.mjs
1import importedPlugin from './imported-plugin'; 2 3export default { 4 plugins: [ 5 // plugin imported from another JavaScript file 6 importedPlugin, 7 8 // plugin defined inline 9 { 10 name: 'customPlugin', 11 params: { 12 paramName: 'paramValue', 13 }, 14 fn: (ast, params, info) => {}, 15 }, 16 ], 17};
SVGO provides a few low level utilities.
The core of SVGO is optimize
function.
1import { optimize } from 'svgo'; 2 3const result = optimize(svgString, { 4 path: 'path-to.svg', // recommended 5 multipass: true, // all other config fields are available here 6}); 7 8const optimizedSvgString = result.data;
If you write a tool on top of SVGO you may want to resolve the svgo.config.mjs
file.
1import { loadConfig } from 'svgo'; 2 3const config = await loadConfig();
You can also specify a path and customize the current working directory.
1const config = await loadConfig(configFile, cwd);
SheetJS LLC | Fontello |
This software is released under the terms of the MIT license.
Logo by André Castillo.
No vulnerabilities found.
Reason
5 commit(s) and 10 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 13/30 approved changesets -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More