@csstools/postcss-slow-plugins

中文文档
3.0.0发布于 2026/01/14MIT-0TypeScriptES Module零依赖近 30 天下载 8万

Identify slow plugins in your PostCSS config

原始使用文档
文档目录6 节
  1. How to measure
  2. Some tips to improve performance
  3. Example output
  4. Usage
  5. Options
  6. ignore

PostCSS Slow Plugins PostCSS Logo

npm install @csstools/postcss-slow-plugins --save-dev

PostCSS Slow Plugins lets you easily check which plugins have the most impact on your build duration.

PostCSS is incredibly fast but adding too many plugins or a few slow ones can still cause issues.

Typical causes of slow PostCSS setups are :

  • you have a lot of CSS
  • you have a lot of plugins
  • a specific plugin is very slow

This plugin is intended to make it visible which plugins are the most impactful on the duration of CSS processing.

We also welcome anyone to report performance issues so that we can improve the performance of popular plugins.
However we ask that everyone is respectful when doing so.
No one is required to fix your performance issue.

We strongly believe that PostCSS setups can and should be fast and efficient.

How to measure

PostCSS Slow Plugins itself is also just a PostCSS plugin.
Simply add it to your config as you would any other plugin and run your build.

This will take a long time.

Seriously, a very long time.

It will profile your build twice for each plugin :

  • once with only that plugin disabled
  • once with only that plugin enabled

When profiling it will run your build 20 times to get a mean duration.

So expect this to take N * 20 * 2 times longer than your normal build.

Some tips to improve performance

  • make sure your browserslist config is accurate and up to date
  • make sure caniuse-lite is up to date
  • add a dev specific config with minimal plugins
  • remove plugins that do trivial things you could do by hand
  • remove plugins for static values that could be generated once

Example output

Analyzing with file:
  plugins/postcss-slow-plugins/test/basic.css

Most impactful to improve, ordered by drop in duration when excluded:
┌─────────┬───────────┬─────────────┬──────────┬──────────────────────────────────────────┬───────────────────────┐
│ (index) │  duration │ kb's per ms │   drop   │                   name                   │ index in plugins list │
├─────────┼───────────┼─────────────┼──────────┼──────────────────────────────────────────┼───────────────────────┤
│    0    │ '10.69ms' │ '0.93kb/ms' │   '--'   │           '-- all plugins --'            │         '--'          │
│    1    │ '6.88ms'  │ '1.45kb/ms' │ '3.80ms' │ 'postcss-gradients-interpolation-method' │           9           │
│    2    │ '7.12ms'  │ '1.40kb/ms' │ '3.56ms' │ 'postcss-progressive-custom-properties'  │          25           │
│    3    │ '7.13ms'  │ '1.40kb/ms' │ '3.55ms' │    'postcss-normalize-display-values'    │          18           │
│    4    │ '7.28ms'  │ '1.37kb/ms' │ '3.41ms' │       'postcss-color-mix-function'       │          10           │
│    5    │ '7.28ms'  │ '1.37kb/ms' │ '3.40ms' │    'postcss-stepped-value-functions'     │          20           │
│    6    │ '7.29ms'  │ '1.37kb/ms' │ '3.39ms' │         'postcss-cascade-layers'         │          23           │
│    7    │ '7.32ms'  │ '1.36kb/ms' │ '3.36ms' │    'postcss-trigonometric-functions'     │          21           │
│    8    │ '7.32ms'  │ '1.36kb/ms' │ '3.36ms' │         'postcss-color-function'         │          14           │
│    9    │ '7.33ms'  │ '1.36kb/ms' │ '3.36ms' │            'postcss-ic-unit'             │          19           │
│   10    │ '7.34ms'  │ '1.36kb/ms' │ '3.35ms' │          'postcss-lab-function'          │          12           │
└─────────┴───────────┴─────────────┴──────────┴──────────────────────────────────────────┴───────────────────────┘
Most impactful to improve, ordered by increase in duration when running alone:
┌─────────┬───────────┬──────────────┬──────────────────────────────────────────┬───────────────────────┐
│ (index) │ duration  │ kb's per ms  │                   name                   │ index in plugins list │
├─────────┼───────────┼──────────────┼──────────────────────────────────────────┼───────────────────────┤
│    0    │ '2.17ms'  │ '4.61kb/ms'  │ 'postcss-gradients-interpolation-method' │           9           │
│    1    │ '2.00ms'  │ '5.00kb/ms'  │     'postcss-relative-color-syntax'      │          11           │
│    2    │ '1.96ms'  │ '5.09kb/ms'  │          'postcss-lab-function'          │          12           │
│    3    │ '1.94ms'  │ '5.14kb/ms'  │       'postcss-color-mix-function'       │          10           │
│    4    │ '1.83ms'  │ '5.46kb/ms'  │            'postcss-nesting'             │           3           │
│    5    │ '1.82ms'  │ '5.50kb/ms'  │          'postcss-custom-media'          │           0           │
│    6    │ '1.81ms'  │ '5.50kb/ms'  │         'postcss-color-function'         │          14           │
│    7    │ '1.76ms'  │ '5.68kb/ms'  │    'postcss-normalize-display-values'    │          18           │
│    8    │ '1.75ms'  │ '5.72kb/ms'  │        'postcss-custom-selectors'        │           4           │
│    9    │ '1.73ms'  │ '5.77kb/ms'  │    'postcss-stepped-value-functions'     │          20           │
│   10    │ '1.72ms'  │ '5.79kb/ms'  │    'postcss-trigonometric-functions'     │          21           │
└─────────┴───────────┴──────────────┴──────────────────────────────────────────┴───────────────────────┘

Usage

Add PostCSS Slow Plugins to your project:

npm install postcss @csstools/postcss-slow-plugins --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssSlowPlugins = require('@csstools/postcss-slow-plugins');

postcss([
    postcssSlowPlugins(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

Options

ignore

The ignore option allows you to skip profiling specific plugins.
This is useful to exclude those plugins that are critical anyway.

postcssSlowPlugins({ ignore: ['postcss-oklab-function'] })

版本与发布记录

@csstools/postcss-slow-plugins 共发布 5 个版本,首次发布于 2023/09/05;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.0.0latest2026/01/149 个月前
2.0.02024/08/042 年前
1.0.22023/12/162 年前
1.0.12023/09/053 年前
1.0.02023/09/053 年前

关于 @csstools/postcss-slow-plugins 的常见问题

@csstools/postcss-slow-plugins 是什么?

Identify slow plugins in your PostCSS config

如何安装 @csstools/postcss-slow-plugins?

在项目目录运行 npm install @csstools/postcss-slow-plugins,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:postcss(^8.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@csstools/postcss-slow-plugins 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@csstools/postcss-slow-plugins 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@csstools/postcss-slow-plugins 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@csstools/postcss-slow-plugins 可以商用吗?

@csstools/postcss-slow-plugins 使用 MIT-0 许可。声明的许可为 MIT-0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@csstools/postcss-slow-plugins 的下载量有多少?

根据 npm 官方下载统计,@csstools/postcss-slow-plugins 在 2026/10/11 – 2026/11/09 这 30 天内被下载 79,926 次,日均约 2,664 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@csstools/postcss-slow-plugins 还在维护吗?

最新版本 3.0.0 发布于 2026/01/14(9 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/09/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。