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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@csstools/postcss-slow-plugins

v1.0.2

Published

Identify slow plugins in your PostCSS config

Downloads

25

Readme

PostCSS Slow Plugins

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 to remove/disable.

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 remove, ordered by drop in duration when excluded:
┌─────────┬────────────┬──────────────┬───────────┬──────────────────────────────────────────┬───────────────────────┐
│ (index) │  duration  │ kb's per ms  │   drop    │                   name                   │ index in plugins list │
├─────────┼────────────┼──────────────┼───────────┼──────────────────────────────────────────┼───────────────────────┤
│    0    │ '10.692ms' │ '0.937kb/ms' │   '--'    │           '-- all plugins --'            │         '--'          │
│    1    │ '6.884ms'  │ '1.455kb/ms' │ '3.808ms' │ 'postcss-gradients-interpolation-method' │           9           │
│    2    │ '7.128ms'  │ '1.405kb/ms' │ '3.564ms' │ 'postcss-progressive-custom-properties'  │          25           │
│    3    │ '7.138ms'  │ '1.403kb/ms' │ '3.554ms' │    'postcss-normalize-display-values'    │          18           │
│    4    │ '7.281ms'  │ '1.376kb/ms' │ '3.411ms' │       'postcss-color-mix-function'       │          10           │
│    5    │ '7.286ms'  │ '1.375kb/ms' │ '3.406ms' │    'postcss-stepped-value-functions'     │          20           │
│    6    │ '7.299ms'  │ '1.372kb/ms' │ '3.393ms' │         'postcss-cascade-layers'         │          23           │
│    7    │ '7.327ms'  │ '1.367kb/ms' │ '3.366ms' │    'postcss-trigonometric-functions'     │          21           │
│    8    │ '7.329ms'  │ '1.367kb/ms' │ '3.363ms' │         'postcss-color-function'         │          14           │
│    9    │ '7.332ms'  │ '1.366kb/ms' │ '3.361ms' │            'postcss-ic-unit'             │          19           │
│   10    │ '7.342ms'  │ '1.364kb/ms' │ '3.350ms' │          'postcss-lab-function'          │          12           │
└─────────┴────────────┴──────────────┴───────────┴──────────────────────────────────────────┴───────────────────────┘
Most impactful to remove, ordered by increase in duration when running alone:
┌─────────┬───────────┬──────────────┬──────────────────────────────────────────┬───────────────────────┐
│ (index) │ duration  │ kb's per ms  │                   name                   │ index in plugins list │
├─────────┼───────────┼──────────────┼──────────────────────────────────────────┼───────────────────────┤
│    0    │ '2.171ms' │ '4.613kb/ms' │ 'postcss-gradients-interpolation-method' │           9           │
│    1    │ '2.000ms' │ '5.007kb/ms' │     'postcss-relative-color-syntax'      │          11           │
│    2    │ '1.965ms' │ '5.097kb/ms' │          'postcss-lab-function'          │          12           │
│    3    │ '1.948ms' │ '5.142kb/ms' │       'postcss-color-mix-function'       │          10           │
│    4    │ '1.833ms' │ '5.465kb/ms' │            'postcss-nesting'             │           3           │
│    5    │ '1.821ms' │ '5.500kb/ms' │          'postcss-custom-media'          │           0           │
│    6    │ '1.819ms' │ '5.507kb/ms' │         'postcss-color-function'         │          14           │
│    7    │ '1.762ms' │ '5.684kb/ms' │    'postcss-normalize-display-values'    │          18           │
│    8    │ '1.750ms' │ '5.724kb/ms' │        'postcss-custom-selectors'        │           4           │
│    9    │ '1.734ms' │ '5.777kb/ms' │    'postcss-stepped-value-functions'     │          20           │
│   10    │ '1.729ms' │ '5.792kb/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 */);

PostCSS Slow Plugins runs in all Node environments, with special instructions for:

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'] })