npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@svg-rs/svgo

v0.0.5

Published

Node.js tool for optimizing SVG files by Rust.

Downloads

9

Readme

svgo-rs

svgo-rs 是一个用 Rust 编写的高性能 SVG 优化器,旨在高效地处理和优化 SVG 文件。它通过 NAPI-RS 提供 Node.js 的绑定,使 JavaScript 和 TypeScript 开发者可以轻松使用。

特性

  • 使用 Rust 编写,性能卓越。
  • 提供多种 SVG 优化插件,例如移除元数据、注释和不必要的元素。
  • 支持多个平台,并提供预编译的二进制文件。
  • 可轻松集成到 Node.js 项目中。

安装

通过 npm 安装此包:

npm install @svg-rs/svgo

使用方法

Node.js

const { optimize } = require('@svg-rs/svgo')

const inputSvg = `<svg xmlns="http://www.w3.org/2000/svg">
  <g attr1="val1">
    <desc>Example</desc>
    <circle cx="50" cy="50" r="40"/>
  </g>
</svg>`

const optimizedSvg = optimize(inputSvg)
console.log(optimizedSvg)

插件

  • [] ddAttributesToSVGElement
  • [] addClassesToSVGElement
  • [] cleanupAttrs
  • [] cleanupEnableBackground
  • [] cleanupIds
  • [] cleanupListOfValues
  • [] cleanupNumericValues
  • [] collapseGroups
  • [] convertColors
  • [] convertEllipseToCircle
  • [] convertOneStopGradients
  • [] convertPathData
  • [] convertShapeToPath
  • [] convertStyleToAttrs
  • [] convertTransform
  • [] inlineStyles
  • [] mergePaths
  • [] mergeStyles
  • [] minifyStyles
  • [x] moveElemsAttrsToGroup
  • [] moveGroupAttrsToElems
  • [] prefixIds
  • [] removeAttributesBySelector
  • [] removeAttrs
  • [x] removeComments
  • [] removeDeprecatedAttrs
  • [x] removeDesc
  • [] removeDimensions
  • [x] removeDoctype
  • [x] removeEditorsNSData
  • [] removeElementsByAttr
  • [] removeEmptyAttrs
  • [] removeEmptyContainers
  • [] removeEmptyText
  • [] removeHiddenElems
  • [x] removeMetadata
  • [] removeNonInheritableGroupAttrs
  • [] removeOffCanvasPaths
  • [] removeRasterImages
  • [] removeScripts
  • [] removeStyleElement
  • [x] removeTitle
  • [] removeUnknownsAndDefaults
  • [] removeUnusedNS
  • [] removeUselessDefs
  • [] removeUselessStrokeAndFill
  • [] removeViewBox
  • [] removeXMLNS
  • [x] removeXMLProcInst
  • [] removeXlink
  • [] reusePaths
  • [] sortAttrs
  • [] sortDefsChildren

基准测试

svgo-rs 相较于基于 JavaScript 的 SVG 优化器提供了显著的性能提升。可以在 benchmark/ 目录中运行基准测试进行比较:

yarn bench

许可证

此项目基于 MIT 许可证授权。详情请参阅 LICENSE 文件。

贡献

欢迎贡献!请在 GitHub 上提交 issue 或 pull request。