Package Exports
- minified-size
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (minified-size) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
minified-size
Estimates the size of minified and gzipped JavaScript files. Check, how much space will a particular script take in the minified output.
Command-line Usage
Make sure that you have NodeJS >= 8 installed. Install the minified-size
package globally:
$ npm install -g minified-size
Print the original, expected minified and gzipped sizes of a sample file:
$ minified-size lib/index.js
lib/index.js: 2.54 kB, 1.48 kB, 643 B
Running minified-size
without any parameters will print usage instructions:
Usage: minified-size [options] <file>, ... | --
Options:
-V, --version output the version number
-j, --json print results in the JSON format
-r, --raw-sizes print sizes in bytes as integers
-o, --no-original-size prevents printing the size of the original code
-m, --no-minified-size prevents printing the size of the minified code
-g, --no-gzipped-size prevents printing the size of the gzipped code
-h, --help output usage information
All three sizes are estimated by default. File paths may contain wildcards.
If "--" is entered instead of files, the standard input will be read.
Programmatic Usage
Make sure that you use NodeJS >= 8. Install the minified-size
package locally:
npm install --save minified-size
Get the original, expected minified and gzipped sizes (in bytes) of a sample file:
const minifiedSize = require('minified-size')
const files = [ 'lib/index.js' ]
const results = await minifiedSize({ files })
// [ { file: 'lib/index.js',
// originalSize: 2544,
// minifiedSize: 1482,
// gzippedSize: 643 } ]
Options
files
- an array of strings with file paths to load and processstreams
- an array of readable streams with source code to processsources
- an array of strings with source code to processgzip
- a boolean to disable estimating the gzipped output size, or an object with options for gzip.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
- 2018-08-31 v0.2.2 Support Windows paths
- 2018-08-31 v0.2.0 Support source code read from standard input
- 2018-08-31 v0.1.0 Support wildcards in the input file paths
- 2018-08-31 v0.0.1 Initial release
License
Copyright (c) 2018-2019 Ferdinand Prantl
Licensed under the MIT license.