CSSOisbasedon[CSSTree](https://github.com/csstree/csstree) to parse CSS into AST, AST traversal and to generate AST back to CSS. All `CSSTree` API is available behind `syntax` field. You may minify CSS step by step:
>Warning:CSSOusesearlyversionsofCSSTreethatstillinactivedevelopment.CSSOdoesn'tguaranteeAPIbehind`syntax` field or AST format will not change in future releases of CSSO, since it's subject to change in CSSTree. Be careful with CSSO updates if you use `syntax`APIuntilthiswarningremoval.
>NOTE:`syntax.compress()` performs AST compression by transforming input AST by default (since AST cloning is expensive and needed in rare cases). Use `clone`optionwithtruthyvalueincaseyouwanttokeepinputASTuntouched.
Togetasourcemapset`true` for `sourceMap` option. Additianaly `filename` option can be passed to specify source file. When `sourceMap` option is `true`, `map` field of result object will contain a [`SourceMapGenerator`](https://github.com/mozilla/source-map#sourcemapgenerator) instance. This object can be mixed with another source map or translated to string.
```js
varcsso=require('csso');
varcss=fs.readFileSync('path/to/my.css','utf8');
varresult=csso.minify(css,{
filename:'path/to/my.css',// will be added to source map as reference to source file
new Buffer(output.map.toString()).toString('base64') +
' */'
);
```
###Usagedata
`CSSO` can use data about how `CSS` is used in a markup for better compression. File with this data (`JSON`) can be set using `usage`option.Usagedatamaycontainfollowingsections:
Allsectionsareoptional.Valueof`tags`, `ids` and `classes` should be an array of a string, value of `scopes`shouldbeanarrayofarraysofstrings.Othervaluesareignoring.
####Whitelistfiltering
`tags`, `ids` and `classes` are using on clean stage to filter selectors that contain something not in the lists. Selectors are filtering only by those kind of simple selector which white list is specified. For example, if only `tags`listisspecifiedthentypeselectorsarechecking,andifalltypeselectorsinselectorpresentinlistorselectorhasnoanytypeselectoritisn'tfilter.
>`ids` and `classes` are case sensitive, `tags`–isnot.
Blacklistfilteringperformsthesameaswhitelistfiltering,butfiltersthingsthatmentionedinthelists.`blacklist` can contain the lists `tags`, `ids` and `classes`.
ScopesisdesignedforCSSscopeisolationsolutionssuchas[css-modules](https://github.com/css-modules/css-modules). Scopes are similar to namespaces and define lists of class names that exclusively used on some markup. This information allows the optimizer to move rules more agressive. Since it assumes selectors from different scopes don't match for the same element. This can improve rule merging.
Ifclassnameisn'tmentionedinthe`scopes` it belongs to default scope. `scopes` data doesn't affect `classes` whitelist. If class name mentioned in `scopes` but missed in `classes`(bothsectionsarespecified)itwillbefiltered.