Size Limit CLI Tool

12.1.0 · active · verified Wed Apr 22

Size Limit is a performance budget command-line interface (CLI) tool for JavaScript projects, designed to prevent web performance regressions. It integrates into CI/CD pipelines (like GitHub Actions, Travis CI, Circle CI) to automatically check bundle size against predefined limits on every commit or pull request. The tool supports ES modules and tree-shaking, providing modular plugins to adapt to various project setups, from large applications to small npm libraries. Rather than just raw bytes, it can calculate the estimated download and execution time for end-users, incorporating all dependencies and polyfills. The current stable version is 12.1.0, with an active release cadence involving frequent patch and minor updates, and major versions released as necessary for breaking changes or significant feature additions.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a basic `.size-limit.js` configuration file to define bundle size limits for multiple files or patterns, and how to execute the tool via `npx`.

/* .size-limit.js */
/** @type {import('size-limit').Config} */
module.exports = [
  {
    path: 'dist/main.js',
    limit: '10 kB',
    name: 'Main Bundle'
  },
  {
    path: 'dist/*.css',
    limit: '2 kB',
    name: 'CSS Stylesheets'
  },
  {
    path: ['dist/vendor.js', 'dist/utils.js'],
    limit: '5 kB',
    webpack: false, // For non-webpack bundles
    gzip: true
  }
];

// To run Size Limit after setting up the config:
// npx size-limit

view raw JSON →