mirror of
https://github.com/mrclay/minify.git
synced 2025-08-19 12:21:20 +02:00
Make CSSmin the default CSS compressor
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
Minify Release History
|
||||
|
||||
(master)
|
||||
Version 3.0.0
|
||||
* Better CSS minification via Túbal Martín's CSSMin
|
||||
* New API incompatible with the 2.x versions
|
||||
* Installation requires use of Composer to install dependencies
|
||||
* Builder styled with Bootstrap (thanks to help from acidvertigo)
|
||||
* Add config option for simply concatenating files
|
||||
|
||||
|
@@ -114,9 +114,9 @@ $min_serveOptions['maxAge'] = 1800;
|
||||
|
||||
|
||||
/**
|
||||
* To use CSSmin (Túbal Martín's port of the YUI CSS compressor), uncomment the following line:
|
||||
* To use the CSS compressor that shipped with 2.x, uncomment the following line:
|
||||
*/
|
||||
//$min_serveOptions['minifiers']['text/css'] = array('Minify_CSSmin', 'minify');
|
||||
//$min_serveOptions['minifiers'][Minify::TYPE_CSS] = array('Minify_CSS', 'minify');
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,13 +1,3 @@
|
||||
## Why do the CSS & HTML minifiers add so many line breaks?
|
||||
|
||||
TL;DR: Ignore them. They don't add to the output size and if you absolutely want all content on one line you will have to use another tool.
|
||||
|
||||
It's [rumored](https://github.com/yui/yuicompressor/blob/master/doc/README#L43) that some source control tools and old browsers don't like very long lines. Compressed files with shorter lines are also easier to diff.
|
||||
|
||||
Since both Minify classes are regex-based, it would be very difficult/error-prone to count characters then try to re-establish context to add line breaks. Instead, both classes trade 1 space for 1 line break (`\n`) wherever possible, adding breaks but without adding bytes.
|
||||
|
||||
If you can think of another safe & efficient way to limit lines in these two tools without adding bytes, please submit a patch, but this is not something anyone should be worrying about.
|
||||
|
||||
## Minify doesn't compress as much as product XYZ. Why not?
|
||||
|
||||
Out of the box, Minify uses algorithms available in PHP, which frankly aren't as solid as competing products, but I consider them _good enough_. At this point I don't have time to work on further tweaking, so if you must have _perfect_ minification you can explore the CookBook to plug in other minifiers. If you'd like to propose specific tweaks in the algorithm (and don't have a patch), please propose these in the Google Group, not the issue tracker.
|
||||
|
@@ -85,7 +85,7 @@ class Minify {
|
||||
|
||||
'minifiers' => array(
|
||||
Minify::TYPE_JS => array('JSMin\\JSMin', 'minify'),
|
||||
Minify::TYPE_CSS => array('Minify_CSS', 'minify'),
|
||||
Minify::TYPE_CSS => array('Minify_CSSmin', 'minify'),
|
||||
Minify::TYPE_HTML => array('Minify_HTML', 'minify'),
|
||||
),
|
||||
'minifierOptions' => array(), // no minifier options
|
||||
@@ -293,7 +293,7 @@ class Minify {
|
||||
if ($this->options['contentType'] === self::TYPE_JS) {
|
||||
$source->setMinifier("");
|
||||
} elseif ($this->options['contentType'] === self::TYPE_CSS) {
|
||||
$source->setMinifier(array('Minify_CSS', 'minify'));
|
||||
$source->setMinifier(array('Minify_CSSmin', 'minify'));
|
||||
$sourceOpts = $source->getMinifierOptions();
|
||||
$sourceOpts['compress'] = false;
|
||||
$source->setMinifierOptions($sourceOpts);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
|
||||
*
|
||||
* @deprecated Use Minify_CSSmin
|
||||
*/
|
||||
class Minify_CSS {
|
||||
|
||||
|
@@ -14,9 +14,17 @@
|
||||
* hacks involving comment tokens in 'content' value strings to break
|
||||
* minimization badly. A test suite is available.
|
||||
*
|
||||
* Note: This replaces a lot of spaces with line breaks. It's rumored
|
||||
* (https://github.com/yui/yuicompressor/blob/master/README.md#global-options)
|
||||
* that some source control tools and old browsers don't like very long lines.
|
||||
* Compressed files with shorter lines are also easier to diff. If this is
|
||||
* unacceptable please use CSSmin instead.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
|
||||
*
|
||||
* @deprecated Use CSSmin (tubalmartin/cssmin)
|
||||
*/
|
||||
class Minify_CSS_Compressor {
|
||||
|
||||
|
@@ -52,7 +52,7 @@ class Minify_Controller_Page extends Minify_Controller_Base {
|
||||
if (isset($options['minifyAll'])) {
|
||||
// this will be the 2nd argument passed to Minify_HTML::minify()
|
||||
$sourceSpec['minifyOptions'] = array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
'cssMinifier' => array('Minify_CSSmin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
);
|
||||
unset($options['minifyAll']);
|
||||
|
@@ -34,7 +34,7 @@ if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin\\JSMin', 'minify');
|
||||
}
|
||||
if (isset($_POST['minCss'])) {
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSSmin', 'minify');
|
||||
}
|
||||
$source = new Minify_Source($sourceSpec);
|
||||
Minify_Logger::setLogger(FirePHP::getInstance(true));
|
||||
@@ -50,14 +50,14 @@ if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
}
|
||||
|
||||
$tpl = array();
|
||||
$tpl['classes'] = array('Minify_HTML', 'JSMin\\JSMin', 'Minify_CSS', 'Minify_CSSmin', 'JSMinPlus');
|
||||
$tpl['classes'] = array('Minify_HTML', 'JSMin\\JSMin', 'Minify_CSS', 'Minify_CSS', 'JSMinPlus');
|
||||
|
||||
if (isset($_POST['method']) && in_array($_POST['method'], $tpl['classes'])) {
|
||||
|
||||
$args = array($textIn);
|
||||
if ($_POST['method'] === 'Minify_HTML') {
|
||||
$args[] = array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
'cssMinifier' => array('Minify_CSSmin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
);
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ if (isset($_POST['url'])) {
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin\\JSMin', 'minify');
|
||||
}
|
||||
if (isset($_POST['minCss'])) {
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSSmin', 'minify');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,12 +7,8 @@ name="description" content="A demonstration of what can be accomplished visually
|
||||
name="robots" content="all" /><title>css Zen Garden: The Beauty in CSS Design</title> <script type="text/javascript">var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
|
||||
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
|
||||
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">/*<![CDATA[*/var i=0;while(++i<10)
|
||||
{}/*]]>*/</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">/*<![CDATA[*/(i<1);/*]]>*/</script> <!--[if IE 6]><style type="text/css">/*<![CDATA[*/
|
||||
/*! copyright: you'll need CDATA for this < & */
|
||||
body{background:white}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
|
||||
hack{}/**/ /*/*/css
|
||||
hack{}/**/css
|
||||
hack{display/**/:/**/none;display:none}</style><link
|
||||
{}/*]]>*/</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">/*<![CDATA[*/(i<1);/*]]>*/</script> <!--[if IE 6]><style type="text/css">/*<![CDATA[*//*! copyright: you'll need CDATA for this < & */
|
||||
body{background:white}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*//**/css hack{display:none;display:none}</style><link
|
||||
rel="Shortcut Icon"
|
||||
type="image/x-icon"
|
||||
href="http://www.csszengarden.com/favicon.ico" /><link
|
||||
|
@@ -7,12 +7,8 @@ name="description" content="A demonstration of what can be accomplished visually
|
||||
name="robots" content="all"><title>css Zen Garden: The Beauty in CSS Design</title> <script type="text/javascript">var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
|
||||
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
|
||||
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">var i=0;while(++i<10)
|
||||
{}</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">(i<1);</script> <!--[if IE 6]><style type="text/css">
|
||||
/*! copyright: you'll need CDATA for this < & */
|
||||
body{background:white}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
|
||||
hack{}/**/ /*/*/css
|
||||
hack{}/**/css
|
||||
hack{display/**/:/**/none;display:none}</style><link
|
||||
{}</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">(i<1);</script> <!--[if IE 6]><style type="text/css">/*! copyright: you'll need CDATA for this < & */
|
||||
body{background:white}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*//**/css hack{display:none;display:none}</style><link
|
||||
rel="Shortcut Icon"
|
||||
type="image/x-icon"
|
||||
href="http://www.csszengarden.com/favicon.ico"><link
|
||||
|
@@ -1,5 +1,2 @@
|
||||
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",Arial Narrow,sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
|
||||
solid #0f7}div#content
|
||||
h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}
|
||||
/*! YUI Compressor style comments are preserved */
|
||||
body{background:#fff url(/path/to/image.gif) repeat-y}
|
||||
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",Arial Narrow,sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px solid #0f7}div#content h1+p{padding-top:0;margin-top:0}@media all and (min-width:640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width:2000px){#media-queries-2{background-color:#0f0}}/*! YUI Compressor style comments are preserved */
|
||||
body{background:#fff url(/path/to/image.gif) repeat-y}
|
@@ -56,7 +56,7 @@ function test_Minify()
|
||||
}
|
||||
|
||||
assertTrue(
|
||||
! class_exists('Minify_CSS', false)
|
||||
! class_exists('Minify_CSSmin', false)
|
||||
,'Minify : minifier classes aren\'t loaded for 304s'
|
||||
);
|
||||
|
||||
|
@@ -10,7 +10,7 @@ function test_HTML()
|
||||
|
||||
$time = microtime(true);
|
||||
$minOutput = Minify_HTML::minify($src, array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
'cssMinifier' => array('Minify_CSSmin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
));
|
||||
$time = microtime(true) - $time;
|
||||
@@ -33,7 +33,7 @@ function test_HTML()
|
||||
|
||||
$time = microtime(true);
|
||||
$minOutput = Minify_HTML::minify($src, array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
'cssMinifier' => array('Minify_CSSmin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
));
|
||||
$time = microtime(true) - $time;
|
||||
|
Reference in New Issue
Block a user