Parses stylesheets and returns an object with statistics
Used in http://cssstats.com
npm install cssstats
var fs = require('fs');
var cssstats = require('csstats');
var css = fs.readFileSync('./styles.css', 'utf8');
var obj = cssstats(css);
The size of the file in bytes
The size of the stylesheet gzipped in bytes
An array of selectors sorted by source order with the selector string, specificity score, and parts array
An object of declarations.
An array of declaration objects from PostCSS.
An object with keys for each property found in the stylesheet.
An object with keys for each unique property/value found in the stylesheet.
An object with keys for each media query found in the stylesheet.
The number of declarations with values that contain !important
The number of declaration properties that have vendor prefixes.
Flattened array of rules from PostCSS.
Aggregate data for the entire stylesheet.
selectors
- total number of selectorsdeclarations
- total number of declarationsproperties
- an array of properties used in the stylesheetmediaQueries
- an array of media query strings used in the stylesheetidSelectors
- total number of selectors containing an idclassSelectors
- total number of selectors containing a classpseudoElementSelectors
- total number of selectors containing an pseudo elementpseudoClassSelectors
- total number of selectors containing a pseudo class
For every unique property found in the stylesheet, aggregates
also includes these values:
[property].total
- total number of [property] declarations[property].unique
- number of unique [property] declarations
See the /test/results
folder for example JSON results.