# grunt-compare-size

> Compare file sizes on this branch to master

Latest version **0.4.2** (published 2016-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install grunt-compare-size
pnpm add grunt-compare-size
yarn add grunt-compare-size
bun add grunt-compare-size
```

Provides the command `grunt-compare-size`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2016-04-24 |
| First published | 2012-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 61 |
| Author | Rick Waldron |
| Maintainers | rwaldron, gibson042 |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-compare-size
- Repository: https://github.com/rwldrn/grunt-compare-size
- Issues: https://github.com/rwldrn/grunt-compare-size/issues
- npm.io page: https://npm.io/package/grunt-compare-size

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.11.1

## Recent versions

- 0.4.2 (latest) — 2016-04-24
- 0.4.1 — 2016-04-24
- 0.4.0 — 2013-12-19
- 0.4.0-rc.3 — 2013-04-13
- 0.4.0-rc.2 — 2013-04-05
- 0.4.0-rc.1 — 2013-03-20
- 0.4.0-alpha.1 — 2013-03-09
- 0.3.1 — 2012-12-19
- 0.3.0 — 2012-12-16
- 0.2.0 — 2012-10-17
- 0.1.7 — 2012-05-07
- 0.1.6 — 2012-04-25
- 0.1.5 — 2012-04-25
- 0.1.4 — 2012-04-24
- 0.1.3 — 2012-04-18
- … 3 more at https://npm.io/package/grunt-compare-size/versions

## README

# grunt-compare-size

Compare file sizes on this branch to master

## Getting Started

Add this to your project's `Gruntfile.js` gruntfile:
```javascript
grunt.loadNpmTasks('grunt-compare-size');
```

Then add "grunt-compare-size" to your package.json dependencies.

Then install the plugin with: `npm install`

The name to use in your own task definitions is `compare_size` (with an underscore).

## Documentation

Add an entry to your Gruntfile.js's `initConfig` object, which will define the files to measure the size of. The last file in the list will also be gzipped and measured.

```js
  ...

  compare_size: {
    files: [
      "library.js",
      "library.min.js"
    ],
    options: {
      // Location of stored size data
      cache: ".sizecache.json",

      // Compressor label-function pairs
      compress: {
        gz: function( fileContents ) {
          return require("gzip-js").zip( fileContents, {} ).length;
        },
        otherCompressorLabel: function( fileContents ) {
          return compressedSize( fileContents );
        },
        ...
      }
    }
  }

  ...
```

To run a size comparison:

```
grunt compare_size
```

To get compressed comparisons of a single file:

```
grunt compare_size::<file>
```

To add a labeled measurement to the saved list of measurements:

```
grunt compare_size:add:<label>:...
```

To remove a labeled measurement:

```
grunt compare_size:remove:<label>:...
```

To view all saved measurements:

```
grunt compare_size:list
```

To clear out all saved measurements:

```
grunt compare_size:empty
```

To clear out all but some saved measurements:

```
grunt compare_size:prune:keep:alsoKeep:...
```


## Testing

Run tests like:

``` bash

# local grunt install
$ grunt

```

## License
Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>, Corey Frang <gnarf@gnarf.net>, Richard Gibson <richard.gibson@gmail.com>, Mike Sherov <mike.sherov@gmail.com>
Licensed under the MIT license.

---
_Source: https://npm.io/package/grunt-compare-size · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
