mirror of
https://github.com/mrclay/minify.git
synced 2025-09-15 00:12:14 +02:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6a5b09a00e | ||
|
93a1edd34b | ||
|
a6531d3481 | ||
|
9de63f3acc | ||
|
ed239fbb8b | ||
|
332f4bc839 | ||
|
79e5a22321 | ||
|
80c01c6f02 | ||
|
b6e4b7f152 | ||
|
a1489b2d8a | ||
|
d041f763c9 | ||
|
8056a4a9fb | ||
|
e3555570ef | ||
|
a8304c5fb3 | ||
|
dfb97a5c85 | ||
|
4626f6c1e0 |
@@ -8,6 +8,9 @@ php:
|
||||
- 5.4
|
||||
- hhvm
|
||||
|
||||
env:
|
||||
- CLOSURE_VERSION: 20161024
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
@@ -25,10 +28,7 @@ install:
|
||||
- composer update --no-interaction --prefer-source
|
||||
|
||||
before_script:
|
||||
- wget -c https://dl.google.com/closure-compiler/compiler-latest.zip -O vendor/compiler-latest.zip
|
||||
- unzip -od vendor/closure-compiler vendor/compiler-latest.zip
|
||||
- ln -sfn ../$(echo vendor/closure-compiler/closure-compiler-*.jar) tests/compiler.jar
|
||||
- java -jar tests/compiler.jar --version
|
||||
- tests/dl-closure.sh
|
||||
|
||||
script:
|
||||
- composer validate
|
||||
|
32
HISTORY.md
32
HISTORY.md
@@ -1,18 +1,24 @@
|
||||
## Version 3.0.0 (unreleased)
|
||||
* The project root is now what is deployed as `min`
|
||||
## Version 3.0.1 (2017-06-09)
|
||||
|
||||
* Update CSSmin to v4, #599, #590
|
||||
|
||||
## Version 3.0.0 (2017-04-03)
|
||||
* Improved CSS minification via Túbal Martín's CSSMin
|
||||
* Easier error identification (just see error_log)
|
||||
* Adds feature to serve static files directly
|
||||
* Installation requires use of Composer to install dependencies
|
||||
* Removes JSMin+ (unmaintained, high memory usage)
|
||||
* Removes DooDigestAuth
|
||||
* Removes Minify_Loader (uses Composer)
|
||||
* Removes Minify_Logger (uses Monolog)
|
||||
* Removes `$min_libPath` option
|
||||
* The Minify, source, and controller components have changed APIs
|
||||
* Better CSS minification via Túbal Martín's CSSMin
|
||||
* Add config option for simply concatenating files
|
||||
* Add config option for altering creation of Minify/MinApp objects
|
||||
* Adds config option for simply concatenating files
|
||||
* Adds config option for altering creation of Minify/MinApp objects
|
||||
* Missing spec no longer redirects, instead links to docs
|
||||
* Installation requires use of Composer to install dependencies
|
||||
* Minify::VERSION is an int that tracks the major version number
|
||||
* BREAKING: The project root is now what gets deployed as `min`
|
||||
* BREAKING: Removes JSMin
|
||||
* BREAKING: Removes JSMin+ (unmaintained, high memory usage)
|
||||
* BREAKING: Removes DooDigestAuth
|
||||
* BREAKING: Removes Minify_Loader (uses Composer)
|
||||
* BREAKING: Removes Minify_Logger (uses Monolog)
|
||||
* BREAKING: Removes `$min_libPath` option
|
||||
* BREAKING: The Minify, source, and controller components have changed APIs
|
||||
|
||||
## Version 2.3.0 (2016-03-11)
|
||||
* Adds `$min_concatOnly` option to just concatenate files
|
||||
@@ -157,4 +163,4 @@
|
||||
* Replaced old JSMin library with a much faster custom implementation.
|
||||
|
||||
## Version 1.0.0 (2007-05-02)
|
||||
* First release.
|
||||
* First release.
|
||||
|
12
README.md
12
README.md
@@ -21,20 +21,20 @@ Post to the [Google Group](http://groups.google.com/group/minify).
|
||||
|
||||
## Installation
|
||||
|
||||
See the [install guide](https://github.com/mrclay/minify/blob/master/docs/Install.wiki.md).
|
||||
See the [install guide](docs/Install.wiki.md).
|
||||
|
||||
## Configuration & Usage
|
||||
|
||||
(Using 2.x? [Here are the 2.x docs](https://github.com/mrclay/minify/tree/2.x/docs).)
|
||||
|
||||
See the [user guide](https://github.com/mrclay/minify/blob/master/docs/UserGuide.wiki.md).
|
||||
See the [user guide](docs/UserGuide.wiki.md).
|
||||
|
||||
Minify also comes with a [URI Builder application](https://github.com/mrclay/minify/blob/master/docs/BuilderApp.wiki.md) that can help you write URLs
|
||||
Minify also comes with a [URI Builder application](docs/BuilderApp.wiki.md) that can help you write URLs
|
||||
for use with Minify or configure groups of files.
|
||||
|
||||
See the [cookbook](https://github.com/mrclay/minify/blob/master/docs/CookBook.wiki.md) for more advanced options for minification.
|
||||
See the [cookbook](docs/CookBook.wiki.md) for more advanced options for minification.
|
||||
|
||||
More [docs are available](https://github.com/mrclay/minify/tree/master/docs).
|
||||
More [docs are available](docs).
|
||||
|
||||
## Unit Testing
|
||||
|
||||
@@ -43,7 +43,7 @@ More [docs are available](https://github.com/mrclay/minify/tree/master/docs).
|
||||
|
||||
## Warnings
|
||||
|
||||
* Minify is designed for efficiency, but, for very high traffic sites, it will probably serve files slower than your HTTPd due to the CGI overhead of PHP. See the [FAQ](https://github.com/mrclay/minify/blob/master/docs/FAQ.wiki.md#how-fast-is-it) and [CookBook](https://github.com/mrclay/minify/blob/master/docs/CookBook.wiki.md) for more info.
|
||||
* Minify is designed for efficiency, but, for very high traffic sites, it will probably serve files slower than your HTTPd due to the CGI overhead of PHP. See the [FAQ](docs/FAQ.wiki.md#how-fast-is-it) and [CookBook](docs/CookBook.wiki.md) for more info.
|
||||
* If you combine a lot of CSS, watch out for [IE's 4096 selectors-per-file limit](http://stackoverflow.com/a/9906889/3779), affects IE 6 through 9.
|
||||
* Minify *should* work fine with files encoded in UTF-8 or other 8-bit encodings like ISO 8859/Windows-1252. By default Minify appends ";charset=utf-8" to the Content-Type headers it sends.
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
"mrclay/jsmin-php": "~2",
|
||||
"mrclay/props-dic": "^2.2",
|
||||
"php": "^5.3.0 || ^7.0",
|
||||
"tubalmartin/cssmin": "~2.4.8-p5"
|
||||
"tubalmartin/cssmin": "~4"
|
||||
},
|
||||
"require-dev": {
|
||||
"firephp/firephp-core": "~0.4.0",
|
||||
|
@@ -26,7 +26,7 @@ Short answer: **use Minify 2.1.4+, use a pre-compressed version of your file, an
|
||||
|
||||
If the error is in your code, enable [debug mode](Debugging.wiki.md) while debugging your code in Firebug or your favorite browser's Javascript debugger. This will insert comments to allow you to keep track of the individual source locations in the combined file.
|
||||
|
||||
If you have Java on your web host, you can use the [wrapper for YUI Compressor](https://github.com/mrclay/minify/blob/master/lib/Minify/YUICompressor.php) instead of JSMin. [This thread](http://groups.google.com/group/minify/browse_thread/thread/f12f25f27e1256fe) shows how a user has done this.
|
||||
If you have Java on your web host, you can use the [wrapper for YUI Compressor](../lib/Minify/YUICompressor.php) instead of JSMin. [This thread](http://groups.google.com/group/minify/browse_thread/thread/f12f25f27e1256fe) shows how a user has done this.
|
||||
|
||||
## Javascript isn't being minified
|
||||
|
||||
@@ -48,7 +48,7 @@ Scriptaculous 1.8.2 (and probably all 1.x) has an [autoloader script](http://git
|
||||
|
||||
If you upload files using [Coda or Transmit](http://groups.google.com/group/coda-users/browse_thread/thread/572d2dc315ec02e7/) or from a Windows PC to a non-Windows server, your new files may end up with the wrong `mtime` (timestamp) on the server, confusing the cache system.
|
||||
|
||||
Setting the [$min\_uploaderHoursBehind option](https://github.com/mrclay/minify/blob/master/config.php#L171) in `config.php` can compensate for this.
|
||||
Setting the [$min\_uploaderHoursBehind option](../config.php#L171) in `config.php` can compensate for this.
|
||||
|
||||
WinSCP has a [Daylight Saving Time option](http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time) that can prevent this issue.
|
||||
|
||||
|
@@ -39,7 +39,7 @@ $min_cachePath = new Minify_Cache_WinCache();
|
||||
|
||||
## Closure Compiler API Wrapper
|
||||
|
||||
An [experimental wrapper for Google's closure compiler API](https://github.com/mrclay/minify/blob/master/min/lib/Minify/JS/ClosureCompiler.php) is available for compressing Javascript. If the API fails for any reason, JSMin is used as the default backup minifier.
|
||||
An [experimental wrapper for Google's closure compiler API](../lib/Minify/JS/ClosureCompiler.php) is available for compressing Javascript. If the API fails for any reason, JSMin is used as the default backup minifier.
|
||||
```php
|
||||
$min_serveOptions['minifiers'][Minify::TYPE_JS] = array('Minify_JS_ClosureCompiler', 'minify');
|
||||
```
|
||||
|
@@ -47,7 +47,7 @@ $controller = new Minify_Controller_Files($env, $sourceFactory);
|
||||
|
||||
## Set up service and controller options
|
||||
|
||||
A single array is used for configuring both the behavior of `Minify::serve` (see the [default options](https://github.com/mrclay/minify/blob/master/lib/Minify.php#L73)) and the controller, which has its own option keys.
|
||||
A single array is used for configuring both the behavior of `Minify::serve` (see the [default options](../lib/Minify.php#L73)) and the controller, which has its own option keys.
|
||||
|
||||
The Files controller only needs one key: `files`: the array of sources to be combined and served.
|
||||
|
||||
|
@@ -4,7 +4,7 @@ The simple JSMin algorithm is the most reliable in PHP, but check the [CookBook]
|
||||
|
||||
## How fast is it?
|
||||
|
||||
If you [serve static files](https://github.com/mrclay/minify/blob/master/static/README.md), it's as fast as your web server, and you should do this for high-traffic sites.
|
||||
If you [serve static files](../static/README.md), it's as fast as your web server, and you should do this for high-traffic sites.
|
||||
|
||||
The PHP-based server is not as fast, but still performs well thanks to an internal cache. Tips:
|
||||
|
||||
|
@@ -36,12 +36,12 @@ cp ${MINIFY}quick-test.css ${MIN}
|
||||
|
||||
Edit `min/index.php` to remove the ``die()`` statement and adjust the `vendor` path as needed.
|
||||
|
||||
**Note:** This does not install the [URL builder](https://github.com/mrclay/minify/blob/master/docs/BuilderApp.wiki.md), but it's not necessary for operation.
|
||||
**Note:** This does not install the [URL builder](BuilderApp.wiki.md), but it's not necessary for operation.
|
||||
|
||||
## Verifing it works
|
||||
|
||||
You can verify it works via these two URLs:
|
||||
|
||||
|
||||
* http://example.org/min/?f=min/quick-test.js
|
||||
* http://example.org/min/?f=min/quick-test.css
|
||||
|
||||
@@ -56,6 +56,6 @@ Write the [Google Group](http://groups.google.com/group/minify) for help.
|
||||
|
||||
## More links
|
||||
|
||||
* [Usage instructions](https://github.com/mrclay/minify/blob/master/docs/UserGuide.wiki.md)
|
||||
* [Cookbook](https://github.com/mrclay/minify/blob/master/docs/CookBook.wiki.md) for more advanced options
|
||||
* [All docs](https://github.com/mrclay/minify/tree/master/docs)
|
||||
* [Usage instructions](UserGuide.wiki.md)
|
||||
* [Cookbook](CookBook.wiki.md) for more advanced options
|
||||
* [All docs](docs)
|
||||
|
@@ -79,8 +79,6 @@ Browse to http://example.com/min/builder/
|
||||
|
||||
The Minify URI Builder will help you create URIs you can use to minify existing files on your site. You can see screenshots and get a feel for this process from this [walkthrough on mrclay.org](http://mrclay.org/index.php/2008/09/19/minify-21-on-mrclayorg/)
|
||||
|
||||
More info here: https://github.com/mrclay/minify/blob/master/MIN.txt
|
||||
|
||||
You may want to disable the [BuilderApp](BuilderApp.wiki.md) when not in use.
|
||||
|
||||
# Far-future Expires headers
|
||||
@@ -110,9 +108,9 @@ Known issue: files with comment-like strings/regexps can cause problems in this
|
||||
|
||||
# Configuration
|
||||
|
||||
See [config.php](https://github.com/mrclay/minify/blob/master/config.php) for general config options.
|
||||
See [config.php](../config.php) for general config options.
|
||||
|
||||
[groupsConfig.php](https://github.com/mrclay/minify/blob/master/groupsConfig.php) holds preset groups of files to minify. (The builder application can help with this).
|
||||
[groupsConfig.php](../groupsConfig.php) holds preset groups of files to minify. (The builder application can help with this).
|
||||
|
||||
[CookBook](CookBook.wiki.md) shows how to customize settings between production/development environments, and between groups.
|
||||
|
||||
|
@@ -517,7 +517,6 @@ class Minify
|
||||
if ($file
|
||||
&& !isset($minifyOptions['currentDir'])
|
||||
&& !isset($minifyOptions['prependRelativePath'])) {
|
||||
|
||||
$minifyOptions['currentDir'] = dirname($file);
|
||||
$source->setMinifierOptions($minifyOptions);
|
||||
}
|
||||
|
@@ -89,6 +89,7 @@ class Minify_CSS
|
||||
$currentDir = $options['currentDir'];
|
||||
$docRoot = $options['docRoot'];
|
||||
$symlinks = $options['symlinks'];
|
||||
|
||||
return Minify_CSS_UriRewriter::rewrite($css, $currentDir, $docRoot, $symlinks);
|
||||
} else {
|
||||
return Minify_CSS_UriRewriter::prepend($css, $options['prependRelativePath']);
|
||||
|
@@ -217,6 +217,7 @@ class Minify_CSS_Compressor
|
||||
if (preg_match($pattern, $m, $n)) {
|
||||
// end hack mode after this comment, but preserve the hack and comment content
|
||||
$this->_inHack = false;
|
||||
|
||||
return "/*/{$n[1]}/**/";
|
||||
}
|
||||
}
|
||||
@@ -224,18 +225,21 @@ class Minify_CSS_Compressor
|
||||
if (substr($m, -1) === '\\') { // comment ends like \*/
|
||||
// begin hack mode and preserve hack
|
||||
$this->_inHack = true;
|
||||
|
||||
return '/*\\*/';
|
||||
}
|
||||
|
||||
if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
|
||||
// begin hack mode and preserve hack
|
||||
$this->_inHack = true;
|
||||
|
||||
return '/*/*/';
|
||||
}
|
||||
|
||||
if ($this->_inHack) {
|
||||
// a regular comment ends hack mode but should be preserved
|
||||
$this->_inHack = false;
|
||||
|
||||
return '/**/';
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,6 @@ class Minify_CSS_UriRewriter
|
||||
|
||||
// normalize symlinks in order to map to link
|
||||
foreach ($symlinks as $link => $target) {
|
||||
|
||||
$link = ($link === '//') ? self::$_docRoot : str_replace('//', self::$_docRoot . '/', $link);
|
||||
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
|
||||
|
||||
@@ -272,6 +271,7 @@ class Minify_CSS_UriRewriter
|
||||
\\s*
|
||||
\\) # )
|
||||
/x';
|
||||
|
||||
return preg_replace($pattern, 'url($1)', $css);
|
||||
}
|
||||
|
||||
@@ -337,6 +337,7 @@ class Minify_CSS_UriRewriter
|
||||
private static function _owlifySvgPaths($css)
|
||||
{
|
||||
$pattern = '~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)url(\(\s*#\w+\s*\))~';
|
||||
|
||||
return preg_replace($pattern, '$1owl$2', $css);
|
||||
}
|
||||
|
||||
@@ -351,6 +352,7 @@ class Minify_CSS_UriRewriter
|
||||
private static function _unOwlify($css)
|
||||
{
|
||||
$pattern = '~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)owl~';
|
||||
|
||||
return preg_replace($pattern, '$1url', $css);
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
use tubalmartin\CssMin\Minifier as CSSmin;
|
||||
|
||||
/**
|
||||
* Wrapper for CSSmin
|
||||
*
|
||||
|
@@ -62,7 +62,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
|
||||
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
|
||||
return mb_strlen($this->_data, '8bit');
|
||||
} else {
|
||||
return strlen($this->_data);;
|
||||
return strlen($this->_data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
|
||||
$ret = apc_fetch($id);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -109,6 +109,7 @@ class Minify_Cache_File implements Minify_CacheInterface
|
||||
{
|
||||
if (!$this->locking) {
|
||||
readfile($this->path . '/' . $id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -208,7 +208,6 @@ class Minify_Source implements Minify_SourceInterface
|
||||
if ($this->filepath
|
||||
&& !isset($this->minifyOptions['currentDir'])
|
||||
&& !isset($this->minifyOptions['prependRelativePath'])) {
|
||||
|
||||
$this->minifyOptions['currentDir'] = dirname($this->filepath);
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ name="robots" content="all" /><title>css Zen Garden: The Beauty in CSS Design</t
|
||||
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{display:none;display:none}</style><link
|
||||
body{background:#fff}/*]]>*/</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
|
||||
|
@@ -8,7 +8,7 @@ name="robots" content="all"><title>css Zen Garden: The Beauty in CSS Design</tit
|
||||
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{display:none;display:none}</style><link
|
||||
body{background:#fff}</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
|
||||
|
16
tests/dl-closure.sh
Executable file
16
tests/dl-closure.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -xe
|
||||
|
||||
: ${CLOSURE_VERSION:=20161024}
|
||||
|
||||
wget -c https://dl.google.com/closure-compiler/compiler-$CLOSURE_VERSION.zip -O vendor/compiler-$CLOSURE_VERSION.zip
|
||||
unzip -od vendor/closure-compiler vendor/compiler-$CLOSURE_VERSION.zip
|
||||
ln -sfn ../vendor/closure-compiler/closure-compiler-v$CLOSURE_VERSION.jar tests/compiler.jar
|
||||
|
||||
# test that version matches
|
||||
out=$(java -jar tests/compiler.jar --version)
|
||||
|
||||
version=$(echo "$out" | awk '/Version:/{print $NF}')
|
||||
version=${version#v}
|
||||
|
||||
test "$version" = "$CLOSURE_VERSION"
|
Reference in New Issue
Block a user