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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lofter-lottie-opt

v1.0.2

Published

A plugin-based Lottie JSON optimizer with configurable presets

Readme

Lottie Optimizer

插件化 Lottie JSON 优化器,灵活组合优化策略,大幅减小动画文件体积。

安装

npm install lofter-lottie-opt -g
# 或
pnpm add lofter-lottie-opt -g

CLI 使用

# 基础用法:优化 Lottie 文件(使用所有默认插件)
lottie-opt input.json output.json

# 指定使用特定插件
lottie-opt input.json -o output.json --plugins remove-unused-assets,simplify-paths

# 禁用某些插件
lottie-opt input.json --disable compress-images

# 自定义插件配置
lottie-opt input.json --plugin-config simplify-paths.tolerance=0.5,compress-images.quality=balanced

# 查看可用插件
lottie-opt --list-plugins

# 详细输出 + 生成报告
lottie-opt input.json --verbose --report

# 预览模式(不保存)
lottie-opt input.json --dry-run

质量验证

# 验证 Lottie 文件质量
lottie-opt validate input.json

# 完整验证 + HTML 报告
lottie-opt validate input.json --report --visual --playback

编程接口

import { optimize } from 'lofter-lottie-opt';

const result = await optimize(lottieData, {
  plugins: ['remove-unused-assets', 'minify-json', 'simplify-paths'],
  pluginOptions: {
    'simplify-paths': { tolerance: 0.3 },
    'minify-json': { compressNames: false }
  }
});

console.log(`${result.stats.originalSize} → ${result.stats.optimizedSize} bytes`);
console.log(`压缩率: ${result.stats.compressionRatio.toFixed(1)}%`);

CLI 参数

| 参数 | 说明 | |------|------| | --plugins <list> | 逗号分隔的插件列表 | | --disable <list> | 禁用的插件列表 | | --plugin-config <config> | 插件配置,格式 plugin.option=value | | -c, --config <path> | 配置文件路径 | | -v, --verbose | 详细日志 | | -r, --report | 生成优化报告 | | --dry-run | 仅分析不保存 | | --show-config | 显示生效的配置 | | --list-plugins | 列出可用插件 |

可用插件

remove-unused-assets

清理未使用的资源,安全无损。BFS 算法扫描,支持预合成嵌套检测。

lottie-opt input.json --plugins remove-unused-assets

simplify-paths

路径简化,使用 RDP 算法减少贝塞尔曲线控制点。

| 配置项 | 默认值 | 说明 | |--------|--------|------| | tolerance | 1.0 | 误差容忍度(像素) | | mode | static-only | 模式:static-only / animated-consistent / all | | minPoints | 6 | 每条路径最少保留点数 | | preserveCorners | true | 保留尖角 |

lottie-opt input.json --plugin-config simplify-paths.tolerance=0.5,simplify-paths.preserveCorners=true

compress-images

图像压缩,支持 WebP/AVIF/JPEG/PNG,自动选择最小体积格式。

| 配置项 | 默认值 | 说明 | |--------|--------|------| | enableWebp | true | 启用 WebP | | enableAvif | false | 启用 AVIF(更小但处理慢) | | quality | balanced | 质量档位:smallest / balanced / lossless | | longEdge | 0 | 限制最长边像素,0=不限制 | | embed | true | 内嵌为 Data URL | | useTinyPNG | false | 使用 TinyPNG 压缩 |

lottie-opt input.json --plugin-config compress-images.enableWebp=true,compress-images.quality=smallest

minify-json

JSON 结构精简,删除元数据、降低精度、压缩名称。

| 配置项 | 默认值 | 说明 | |--------|--------|------| | removeMetadataKeys | true | 删除 ix/mn/bm/ddd 等元数据 | | enableGlobalPrecision | true | 全局数值精度控制 | | removeDefaultValues | true | 删除默认值(bm:0, hd:false 等) | | keepMatchName | true | 保留 matchName 兼容性 | | compressNames | true | 压缩名称为单字符 | | keepIds | false | 保留原始 ID(否则转短码) |

lottie-opt input.json --plugin-config minify-json.compressNames=false,minify-json.keepIds=true

推荐配置

| 场景 | 命令 | |------|------| | 保守优化 | --plugins remove-unused-assets | | 平衡优化 | --plugins remove-unused-assets,minify-json,simplify-paths | | 激进优化 | 默认(全部插件) |

许可证

MIT