GithubHelp home page GithubHelp logo

grunt-compare-size's Introduction

grunt-compare-size

Compare file sizes on this branch to master

Getting Started

Add this to your project's Gruntfile.js gruntfile:

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.

  ...

  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:

# local grunt install
$ grunt

License

Copyright (c) 2012 Rick Waldron [email protected], Corey Frang [email protected], Richard Gibson [email protected], Mike Sherov [email protected] Licensed under the MIT license.

grunt-compare-size's People

Contributors

dmethvin avatar gibson042 avatar jzaefferer avatar krinkle avatar mikesherov avatar rdworth avatar rwaldron avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.