Skip to content

Estimates the size of your files in different format (original, minified, gzipped, brotli).

License

Notifications You must be signed in to change notification settings

Xelzs/code-size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeSize

Maintainability

Estimates the size of your files in different format (original, minified, gzipped, brotli).

Command-line Usage

Install code-size package globally with npm :

$ npm install -g @xelzs/code-size

Basic usage :

$ code-size -f test.css -gbm --language css

CodeSize | Version 1.0.0

Original size : 9.11 KB
Minified size : 7.16 KB
Gzipped size : 140 Bytes
Brotli size : 82 Bytes

Available options :

Usage: code-size [options]

Options:
  -V, --version              output the version number
  -s, --source <code>        specify raw source code
  -f, --file <path>          specify path to a file
  -g, --gzip                 show gzipped size
  -b, --brotli               show brotli size
  -m, --minify               show minified size | !! Works only with supported language !!
  -l, --language <language>  specifies the language type. Supported: css, sass, scss, js (default: "css")
  -h, --help                 display help for command

Programmatic Usage

Install with npm :

$ npm install --save @xelzs/code-size

Get all sizes :

const {size} = require('code-size');

const data = size({
  file: 'test.css',
  gzip: true,
  brotli: true,
  minify: true,
  language: 'css',
});

console.log(data);
// {
//   original: '9.11 KB',
//   minify: '7.16 KB',
//   gzip: '140 Bytes',
//   brotli: '82 Bytes',
// }

Options

All options availables on command-line are also available here.

  • source - Raw source code
  • file - Path to a file
  • gzip - Boolean to enable the gzip estimation
  • brotli - Boolean to enable the brotli estimation
  • minify - Boolean to enable the minify estimation. Language option required
  • language - Specify the language type. Supported: css, sass, scss, js.

Changelog

Changelog is accessible in the CHANGELOG.md file or in the release section.