CssMin - A (simple) css minifier with benefits
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a CSS token class. Every token has to extend this class. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a for a ruleset start token. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a for ruleset end token. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a parser plugin. Every parser plugin have to extend this class. A parser plugin contains the logic to parse one or aspects of a stylesheet. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a minifier plugin class. Minifier plugin process the parsed tokens one by one to apply changes to the token. Every minifier plugin has to extend this class. /Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a minifier filter class. Minifier filters allows a pre-processing of the parsed token to add, edit or delete tokens. Every minifier filter has to extend this class. /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract formatter definition. Every formatter have to extend this class. /Formatter http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a ruleset declaration token. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a for at-rule block start token. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 Abstract definition of a for at-rule block end token. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssFromatter Formatter} returning the CSS source in http://goo.gl/etzLs Whitesmiths indent style}. /Formatter http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will process var-statement and sets the declaration value to the variable value. This plugin only apply the variable values. The variable values itself will get parsed by the CssVariablesMinifierFilter}. Example: { defaultColor: black; } color: var(defaultColor);
Will get converted to: color:black;
/Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} will parse the variable declarations out of at-rule blocks. The variables will get store in the CssVariablesMinifierPlugin} that will apply the variables to declaration. /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for preserve parsing url() values. This plugin return no aCssToken CssToken} but ensures that url() values will get parsed properly. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for preserve parsing string values. This plugin return no aCssToken CssToken} but ensures that string values will get parsed properly. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} sorts the ruleset declarations of a ruleset by name. /Minifier/Filters http://code.google.com/p/cssmin/ Rowan Beentje http://assanka.net Rowan Beentje http://assanka.net http://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the start of a ruleset. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing ruleset block with including declarations. Found rulesets will add a CssRulesetStartToken} and CssRulesetEndToken} to the parser; including declarations as CssRulesetDeclarationToken}. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the end of a ruleset. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a ruleset declaration. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} will remove any empty rulesets (including at-rule block rulesets). /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} will remove any comments from the array of parsed tokens. /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 CSS Parser. /Parser http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssFromatter Formatter} returning the CSS source in http://goo.gl/j4XdU OTBS indent style} (The One True Brace Style). /Formatter http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} is a utility token that extends aNullToken} and returns only a empty string. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 CSS Minifier. /Minifier http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} import external css files defined with the at-rule into the current stylesheet. /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for preserve parsing expression() declaration values. This plugin return no aCssToken CssToken} but ensures that expression() declaration values will get parsed properly. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 CSS Error. http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will convert a color value in rgb notation to hexadecimal notation. Example: color: rgb(200,60%,5);
Will get converted to: color:#c89905;
/Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will convert named color values to hexadecimal notation. Example: color: black; border: 1px solid indigo;
Will get converted to: color:#000; border:1px solid #4b0082;
/Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} triggers on CSS Level 3 properties and will add declaration tokens with browser-specific properties. /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierFilter minifier filter} will convert at-rule block to browser specific counterparts. /Minifier/Filters http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will convert a color value in hsl notation to hexadecimal notation. Example: color: hsl(232,36%,48%);
Will get converted to: color:#4e5aa7;
/Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will convert the font-weight values normal and bold to their numeric notation. Example: font-weight: normal; font: bold 11px monospace;
Will get converted to: font-weight:400; font:700 11px monospace;
/Minifier/Pluginsn http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will compress several unit values to their short notations. Examples: padding: 0.5em; border: 0px; margin: 0 0 0 0;
Will get compressed to: padding:.5px; border:0; margin:0;
/Minifier/Plugins Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} compress the content of expresssion() declaration values. For compression of expressions https://github.com/rgrove/jsmin-php/ JSMin} will get used. JSMin have to be already included or loadable via http://goo.gl/JrW54 PHP autoloading}. /Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssMinifierPlugin} will convert hexadecimal color value with 6 chars to their 3 char hexadecimal notation (if possible). Example: color: #aabbcc;
Will get converted to: color:#abc;
/Minifier/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a CSS comment. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing comments. Adds a CssCommentToken} to the parser if a comment was found. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the start of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing at-rule block with including declarations. Found at-rule blocks will add a CssAtVariablesStartToken} and CssAtVariablesEndToken} to the parser; including declarations as CssAtVariablesDeclarationToken}. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the end of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a declaration of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the start of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing at-rule block. Found at-rule blocks will add a CssAtMediaStartToken} and CssAtMediaEndToken} to the parser. This plugin will also set the the current media types using CssParser::setMediaTypes()} and CssParser::unsetMediaTypes()}. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the end of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the start of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the start of a ruleset of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the end of a ruleset of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a ruleset declaration of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing at-rule blocks, rulesets and declarations. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the end of a at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a at-rule. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1.b1 (2001-02-22) aCssParserPlugin Parser plugin} for parsing at-rule. If a at-rule was found this plugin will add a CssAtImportToken} to the parser. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the start of a -face at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing -face at-rule block with including declarations. Found -face at-rule blocks will add a CssAtFontFaceStartToken} and CssAtFontFaceEndToken} to the parser; including declarations as CssAtFontFaceDeclarationToken}. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents the end of a -face at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a declaration of a -face at-rule block. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 This aCssToken CSS token} represents a at-rule. /Tokens http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1 aCssParserPlugin Parser plugin} for parsing at-rule. If a at-rule was found this plugin will add a CssAtCharsetToken} to the parser. /Parser/Plugins http://code.google.com/p/cssmin/ Joe Scylla joe.s 2008 - 2011 Joe Scylla cyll a@gma il.c omjoe.s cyll a@gma il.c omhttp://opensource.org/licenses/mit-license.php MIT License 3.0.1