Built in CSS minifiers - Taritsyn/WebMarkupMin GitHub Wiki
CSS minifiers are used in HTML and XHTML minifiers for minification of embedded and inline CSS code. Be a CSS minifier can any class, that implements the ICssMinifier interface.
KristensenCssMinifier class implements a simple CSS minifier based on the Mads Kristensen's Efficient stylesheet minifier.
When creating an instance of the KristensenCssMinifier class, we can pass a minification settings through the constructor:
var cssSettings = new KristensenCssMinificationSettings
{
RemoveRedundantSelectors = true,
RemoveUnitsFromZeroValues = true
})
var cssMinifier = new KristensenCssMinifier(cssSettings);And now let's consider in detail properties of the KristensenCssMinificationSettings class:
| Property name | Data type | Default value | Description |
|---|---|---|---|
RemoveRedundantSelectors |
Boolean |
false |
Flag for whether to remove redundant selectors (e.g. a#btnResetPassword → #btnResetPassword).
|
RemoveTrailingSemicolons |
Boolean |
true |
Flag for whether to remove trailing semicolons after the last declarations. |
RemoveUnitsFromZeroValues |
Boolean |
false |
Flag for whether to remove units from zero values. Units to be removed: If in your code declares custom properties (variables) or calls the following functions: |
If in your HTML/XHTML code is missing embedded or inline CSS code, you can use instead of the real CSS minifier the stub in the form of NullCssMinifier class. This will allow you to save memory.