|
|
News
Steve Clay is now co-owner of Minify and is a large way through a complete refactoring of Minify's codebase. The new code will improve and add several features (see "Upcoming Features" below) and allow Minify's components to be used individually for more custom needs. See VersionTwo for more info.
Ryan Grove created Minify, but no longer has time to perform much maintenance. You may contact Steve (steve@mrclay.org) or Ryan (ryan@wonko.com) if you're interested in joining the project.
Overview
Web pages that refer to multiple CSS or JavaScript files often suffer from slower page loads, since the browser must request each referenced file individually. Most browsers will only make two simultaneous requests to a single server. The latency involved in opening multiple requests and waiting for them to finish before making new requests can result in a user-visible delay, and that can make your users sad.
Minify attempts to fix this problem by combining multiple CSS or JavaScript files into one download. By default, it also removes comments and unnecessary whitespace to decrease the amount of data that must be sent to the browser. Most importantly, it does all of this on the fly and requires only a few simple changes to your existing web pages.
In particular, Minify helps you follow rules 1, 10, and 13 of Yahoo!'s Rules for High Performance Web Sites. The version in development will also help you follow rules 3, 4, and 14.
Features
- Combines and minifies multiple CSS or JavaScript files into a single download on the fly.
- Uses a PHP implementation of Douglas Crockford's excellent JSMin library for JavaScript minification.
- Caches results to avoid doing unnecessary work.
- Responds with an HTTP 304 (Not Modified) response when the browser already has the requested content in its cache.
- Automatically rewrites relative URLs in combined CSS files to point to the correct location.
- Written in a highly efficient, maintainable, and easily extensible style.
- Written with security as a primary concern; unlike some similar utilities, Minify will never allow the client to request a file it shouldn't have access to.
- Extremely fast; with caching enabled, Minify is capable of handling hundreds of requests per second on a moderately powerful server.
Upcoming Features
- Content-Encoding: gzip/deflate/compress, based on request headers
- Expanded CSS and HTML minifiers with test cases
- Easily plug-in 3rd-party minifiers (Packer will be included)
- Plug-able front end controller allows changing the way files are chosen
- Compression & encoding modules lazy-loaded as needed (304 responses use minimal code)
- Separate utility classes for HTTP encoding and cache control
Requirements
- PHP 5.2.1+
Installation
For installation and usage instructions, see the User Guide.
Acknowledgments
Minify was inspired by jscsscomp by Maxim Martynyuk and by the article 'Supercharged JavaScript' by Patrick Hunlock.
The JSMin library used for JavaScript minification was originally written by Douglas Crockford and was ported to PHP by Ryan Grove specifically for use in Minify.
