-
Notifications
You must be signed in to change notification settings - Fork 472
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 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.
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.
With Minify you will ideally serve fewer requests, but Minify can be slower than your HTTPd serving flat files. If you have a high-traffic site with hundreds of simultaneous requests from new users, you should probably:
- Use the APC/Memcache adapters.
- Revision your Minify URIs (so far-off Expires headers will be sent). One way to do this is using predefined groups and the Minify_groupUri() utility function.
- Place your HTTPd behind a reverse proxy to cache the Minify URLs.
- Benchmark Minify on your development server before rolling out to production.
Ideally, but a couple other goals come first. For Apache users we're designing a feature to enable minified and pre-encoded files to be served directly from the HTTPd. Requests will not execute PHP at all and be blazingly fast (for varying definitions of "blazingly").
Yahoo's Combo Handler and Google's AJAX Libraries API both serve content from their heavy-duty CDNs and potentially increase the chance that your visitor will already have a file in her browser cache. Neither service serves custom content that you provide. You may wish to use these services to serve popular libraries and Minify to serve your code.
If you get a link to this page in response to a request for help, please make sure that you're using the software downloaded from this project (or on github), and have followed the directions.
There are many projects with "minify" in the title/description but don't have anything to do with this project, or which many only use a few components from this project.
Although you may be able to get support for usage of the components, the Google Group members/project owners may not be able to offer any helpful advice with unrelated projects.
Yes. Based on the browser's Accept-Encoding header, Minify will serve content encoded with deflate or gzip.
Of course, and you can also use APC for content caching.
Yes, but it's not a straightforward setup, and probably best avoided.
Yes, but only in the form of a PHP class: Minify_HTML. It also can accept callbacks to minify embedded STYLE and SCRIPT elements.
Since Minify_HTML is not fast, there's no easy way to integrate it into dynamic pages, and you'll have to search the archives for ideas of how to use it. One opportunity would be when storing HTML (assuming writes are infrequent); e.g., in a DB keep one copy for editing and one minified for serving.
Minify is not suited for serving HTML pages on a site, though it can be done for small numbers of static pages. Look the the Page controller.
In 2.1, by default, 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.
I'd love to know. 2.1.1 had 54K downloads and I know the library is powering several plugins these days, at least 3 for WordPress.
Yes. Minify is distributed under the New BSD License, which means that you're free to use, modify, and redistribute Minify or derivative works thereof, even for commercial purposes, as long as you comply with a few simple requirements. See the LICENSE.txt file for details.
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, multiple seconds. (You can get accurate response times using an HTTP inspector like Firebug.)
If you have file access to the server you can check your cache path directly for filenames beginning with "minify