The simple JSMin algorithm is the most reliable in PHP, but check the CookBook to plug in other minifiers.
If you serve static files, 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:
- Use a reverse proxy to cache the Minify URLs. This is by far the most important tip.
- Revision your Minify URIs (so far-off Expires headers will be sent). One way to do this is using groups and the Minify_groupUri() utility function. Without this, clients will re-request Minify URLs every 30 minutes to check for updates.
- Use the APC/Memcache adapters.
Yes. Based on the browser's Accept-Encoding header.
Yes, and you can also use APC for content caching.
Yes, but it's not a straightforward setup, and probably best avoided.
The class Minify_HTML
can do this (and minify embedded STYLE and SCRIPT elements), but it's too slow to use directly. You'd want to integrate it into a system that caches the output. E.g., in a CMS, keep one copy for editing and one minified for serving.
Minify allows files to be specified using the URI, or using pre-configured sets of files. With URI-specified files, Minify is very careful to serve only JS/CSS files that are already public on your server, but if you hide public directories--with .htaccess, e.g.--Minify can't know that. Obvious Tip: don't put sensitive info in JS/CSS files inside DOC_ROOT :)
An included option can disable URI-specified files so Minify will serve only the pre-configured file sets.
The libraries are used in many CMS's and frameworks, but the use of index.php
to serve URLs like http://example.com/min/f=hello.js probably is rare. Minify is made to drop in place to boost small to medium sites not already built for performance.
Version 2.1.1 had 54K downloads.
Yes. Minify is distributed under the New BSD License.
The easiest way is to place a Minify URL directly in your browser's address bar and refresh (F5), which should override the client-side caching that Minify specifies and force Minify to send you a complete response. With cache working, this response should take 100ms or so. Without cache, it could be multiple seconds.
If you have file access to the server you can check your cache path directly for filenames beginning with minify_
.