// the find
ai/size-limit
Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
Size Limit is a CLI that measures what your JavaScript costs end users: minified, compressed bundle size, plus optional headless-Chrome parse and execution time. It fails the run when a configured limit is exceeded, so it works as a CI gate on bundle growth for both shipped apps and published npm libraries. The README is clear about which plugin and preset to pick for each case.
- The plugins are split by concern. 'file' measures bytes with Brotli, gzip, or nothing, 'webpack', 'esbuild', and 'rolldown' produce the bundle, and 'time' is optional. You can turn execution-time measurement on only for the checks that need it, and disable a bundler per check with 'webpack: false' or 'disablePlugins'.
- The 'import' option measures tree-shaken output for a specific export, such as '{ createStore }', instead of the whole entry. For a library, that is the number consumers actually pay for.
- Config can live in package.json, a JSON file, or a JS or TS file, and '--limit' covers one-off checks. 'ignore' removes named dependencies from the total, which helps when a large peer is provided by the host app.
- '--why' attributes cost to individual modules through Statoscope, and 'compareWith' diffs against another build's stats. That turns a failed limit into a concrete answer about which dependency caused it.
- The time metric is the weakest part, and the README says so. It depends on headless Chrome, the CPU throttle is calibrated against a Snapdragon 410, and results vary with the runner. On shared CI machines expect noise, and a tight time limit will flake unless you leave generous headroom.
- Setup is spread across bundlers and presets. The big-lib preset pulls in webpack, and '--why' needs a separate '-why' package for each bundler. The 'just add a size script' path in the first section is shorter than what most real projects end up configuring.
- PR commenting lives in a separate action repo (andresz1/size-limit-action). The CLI itself only passes or fails, and it does not report deltas against the base branch. Teams that want diff comments have to wire that up and keep the action's version in step with the CLI.