Optimisations

What are optimisations?

An optimisation is a module that performs a transform on some CSS code in order to reduce its size, or failing this, the final gzip size of the CSS. Each optimisation is performed by either one module or a few modules working together.

Due to the nature of dividing cssnano's responsibilities across several modules, there will be some cases where using a transform standalone will not produce the most optimal output. For example, postcss-colormin will not trim whitespace inside color functions as this is handled by postcss-normalize-whitespace.

What optimisations do you support?

The optimisations are different depending on which preset cssnano is configured with; with the default preset, we offer safe transforms only.

defaultadvanced
autoprefixer❌✅
cssDeclarationSorter✅✅
rawCache✅✅
calc✅✅
colormin✅✅
convertValues✅✅
discardComments✅✅
discardDuplicates✅✅
discardEmpty✅✅
discardOverridden✅✅
discardUnused❌✅
mergeIdents❌✅
mergeLonghand✅✅
mergeRules✅✅
minifyFontValues✅✅
minifyGradients✅✅
minifyParams✅✅
minifySelectors✅✅
normalizeCharset✅✅
normalizeDisplayValues✅✅
normalizePositions✅✅
normalizeRepeatStyle✅✅
normalizeString✅✅
normalizeTimingFunctions✅✅
normalizeUnicode✅✅
normalizeUrl✅✅
normalizeWhitespace✅✅
orderedValues✅✅
reduceIdents❌✅
reduceInitial✅✅
reduceTransforms✅✅
svgo✅✅
uniqueSelectors✅✅
zindex❌✅

You can read more about presets in our presets guide.

Last updated on by anikethsaha