Minify is a PHP Web compression application developed with PHP5, which improves website performance by following some of Yahoo's optimization rules. It merges multiple CSS or JavaScript files, removes unnecessary spaces and comments, makes gzip compression, and sets the browser's cache header. Minify is designed to resemble Yahoo's Combo Handler service, but minify can merge any JavaScript and CSS files you want to merge. In general, site speed bottlenecks are in the front, and the most critical is the load speed of resources, but most browsers have a single domain number of concurrent requests limit, so if there is a lot of resources in a page, such as CSS and JavaScript files, it will obviously reduce the loading speed of the site, The better way is to access multiple files through a single request, which will not affect the previous file maintenance, but also reduce the clear amount of resources, Minify is born.
Characteristics:
Merging multiple CSS or JavaScript files into one file, reducing the number of requests, and minify processing
Uses multiple open source libraries, including jsmin.php, Minify css,minify HTML
Server-Side Caching (Fils/apc/memcache) to avoid unnecessary duplication of processing
When the browser has a cache of resources, return HTTP 304 not Modified
Automatically generate URIs when multiple files are merged
When server-side caching is turned on, Minify can handle up to hundreds of concurrent requests per second on average servers
Turn on the content-encoding:gzip according to the request header. Minify provides gzipped files faster than Apache's Mod_deflate module in case server-side cache is turned on
Minify Installation and use
Download the latest minify, then unzip the file to the "Min" folder
Copy the "Min" folder to the root of your site, if you want minify to work in a subdirectory
Assuming the site domain name is http://www.scutephp.com,Minify installed in the root directory of the virtual host, then visit http://www.scutephp.com/min/, we will see a "minify URI Builder", We can use our own generated tool to generate compression to merge our JS files and CSS files.
Minify when the resource is requested for the first time, it will merge, Gzip, remove whitespace, comment and so on, and then cache the processed results, by default the file cache, the cache key starts with Minify_, modifies min/ config.php file, configure the location where the cache files are stored.
$min _cachepath = '/tmp ';
In addition to caching through files, Minify also supports memcache caching, modifying min/index.php files, and adding the following code:
Require ' lib/minify/cache/memcache.php ';
$memcache = new Memcache;
$memcache->connect (' localhost ', 11211);
$min _cachepath = new Minify_cache_memcache ($memcache);
Minify supports two debug modes, one is to debug PHP errors by firephp, modify the min/config.php file, and add the following code:
$min _errorlogger = true;
The other is to debug the error by adding flag to the URL, adding the min/config.php in the
$min _allowdebugflag = true;
Then you can debug it in http://www.scutephp.com/min/f=jquery-a.js,jquery-b.js,jquery-c.js&debug=1 mode.
Project Address: http://code.google.com/p/minify/