Git Product home page Git Product logo

minify's Introduction

Minify is no longer regularly maintained

The original authors no longer recommend using Minify, especially previous versions, which were not designed to handle modern JS and CSS syntax. Instead, use an up-to-date performance measurement tool like Lighthouse and follow its recommendations.

In 2010, Minify offered a fine improvement for some websites, but browsers and HTTP servers are now much better, and Minify may offer only a marginal performance benefit in narrow cases. Also both JS and CSS now change rapidly, and new syntaxes are likely to lead to broken code being served through Minify.

About

Minify is an HTTP server for JS and CSS assets. It compresses and combines files and serves it with appropriate headers, allowing conditional GET or long-Expires.

Before 7 requests
After 2 requests

The stats above are from a brief walkthrough which shows how easy it is to set up Minify on an existing site. It eliminated 5 HTTP requests and reduced JS/CSS bandwidth by 70%.

Relative URLs in CSS files are rewritten to compensate for being served from a different directory.

Static file serving

Version 3 allows serving files directly from the filesystem for much better performance. We encourage you to try this feature.

Support

Post to the Google Group.

Installation

See the install guide.

Configuration & Usage

(Using 2.x? Here are the 2.x docs.)

See the user guide.

Minify also comes with a URI Builder application that can help you write URLs for use with Minify or configure groups of files.

See the cookbook for more advanced options for minification.

More docs are available.

Unit Testing

  1. Install dev deps via Composer: composer install
  2. composer test or phpunit

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 and CookBook for more info.
  • If you combine a lot of CSS, watch out for IE's 4096 selectors-per-file limit, 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.

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.

minify's People

Contributors

0m3r avatar acidvertigo avatar adambalint-srg avatar benface avatar dargmuesli avatar demidovsky avatar fisharebest avatar glensc avatar grahamcampbell avatar jasonvarga avatar joec4i avatar joscha avatar jrchamp avatar kendallhopkins avatar ktomega avatar meven avatar mikeotown avatar mrclay avatar mzronek avatar otzy avatar panvid avatar rgrove avatar robations avatar robbykrlos avatar rossbearman avatar santoja avatar simonsimcity avatar tamakianimalife avatar tubalmartin avatar venkatraj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minify's Issues

Adding a version number to URL to force browser to re-request file

Currently, I use a mod_rewrite rule like this:

RewriteRule ^(.*?)\.v[0-9]+\.js$ /js/$1.js [L,E=VERSIONED_FILE:1]
Header add "Expires" "Mon, 28 Jul 2014 23:30:00 GMT" env=VERSIONED_FILE
Header add "Cache-Control" "max-age=315360000" env=VERSIONED_FILE

So I can request my JavaScript file at /js/myjavascript.js as /js/myjavascript.v15.js which forces clients to re-download a new version if I make any important changes. This is great, but I would love to have an easy way to do this with Minified-on-the-fly requests (something like /min/f=/js/myjavascript.js;v15).

I could add a variable to the query string, but some browsers and proxies do not cache resources that contain a query string.

Getting "The connection was reset" while trying to minify css

Firefox 19.0.2, Windows 7 64bits, PHP 5.4.11, Apache/2.2.23 (Win32)

When using ?debug=1, the file compiles with no error. When I try to use the groupConfig without the ?debug=1, I get a connection reset. The GET request isn't even showing in Apache access.log. There are nothing on error.log as well. I enabled FirePHP, but it doesn't give me any hint.

Works fine for JS though.

YUICompressor should alert when java executable is not found or went wrong

Right now when java cannot be executed correctly no exception is raised.

In Minify/YUICompressor.php

I think the code :

private static function _prepare()
{
    if (! is_file(self::$jarFile) 
        || ! is_dir(self::$tempDir)
        || ! is_writable(self::$tempDir)
    ) {
        throw new Exception('Minify_YUICompressor : $jarFile and $tempDir must be set.');
    }
}

Should be replaced by something like :

private static function _prepare()
{
    if (! is_file(self::$jarFile) 
        || ! is_dir(self::$tempDir)
        || ! is_writable(self::$tempDir)
        || ! is_exectuable(self::$jarFile) 
    ) {
        throw new Exception('Minify_YUICompressor : $jarFile and $tempDir must be set.');
    }
}

And

private static function _minify($type, $content, $options)
{
    self::_prepare();
    if (! ($tmpFile = tempnam(self::$tempDir, 'yuic_'))) {
        throw new Exception('Minify_YUICompressor : could not create temp file.');
    }
    file_put_contents($tmpFile, $content);
    //echo self::_getCmd($options, $type, $tmpFile);
    exec(self::_getCmd($options, $type, $tmpFile), $output);
    unlink($tmpFile);
    return implode("\n", $output);
}

By :

private static function _minify($type, $content, $options)
{
    self::_prepare();
    if (! ($tmpFile = tempnam(self::$tempDir, 'yuic_'))) {
        throw new Exception('Minify_YUICompressor : could not create temp file.');
    }
    file_put_contents($tmpFile, $content);
    //echo self::_getCmd($options, $type, $tmpFile);
    exec(self::_getCmd($options, $type, $tmpFile), $output, $return_var);
    unlink($tmpFile);
    if($return_var != 0){
            throw new Exception('Minify_YUICompressor : yuicompressor execution failed.');
    }
    return implode("\n", $output);
}

Log 500 errors

It seems that my Apache is not correctly logging 500 errors generated by minify, for example when a JS file has a syntax error and the compiler can't minify it.

I'm using ClosureCompiler:

$min_serveOptions['minifiers']['application/x-javascript'] = array('Minify_JS_ClosureCompiler', 'minify');

All my other 500 errors seem to be correctly reported in /var/log/apache2/error.log.
I tried debugging a little but I'm not sure where to look nor I'm sure it's a minify issue.

Option for comment removal in the HTML minifier

I use the library for a TYPO3 frontend compressor. Unfortunately the removal of HTML comments is hard coded respectively can't be configured from the caller by using options.

My problem here is, TYPO3 indexed search uses HTML comments to markup the content of a page (<!--TYPO3SEARCH_begin--> and <!--TYPO3SEARCH_end-->). So the only possibility here for me is either to change your code or to derive from Minify_HTML which is not optimal when updates come in.

Better would be a boolean option to enable/disable the removal or even better a regexp (e.g. TYPO3SEARCH_(begin|end)). This would also be nice, since IE 10 no longer supports conditional comments.

How to use URI that incorporates cache ID?

Given an array of stylesheet or javascript includes, how can I update cache and retrieve ID so that they can be included like below?

(when gzip is supported)
<link href="/min/cache/904c0ffe0aa5d4cac486e49803aa6eb5.gz" type="text/css" rel="stylesheet" />
or
<link href="/min/cache/904c0ffe0aa5d4cac486e49803aa6eb5" type="text/css" rel="stylesheet" />

There are several motivations for this approach:

  • obfuscate URIs
  • shorter URIs

Would the performance penalties of this approach be too significant?

Many thanks

JSMin 2.1.7 failes to minify CKEditor 4

I'm using Minify/2.1.7 and CKEditor 4.0 (revision 769d96134b).

There is a line in ckeditor.js (230):

...);return a.replace(/(['"]).*?\1/g,function(a){return ...

JSMin throws an exception:

Unterminated String at byte 107177: '"]).*?\\1/g,function(a){return ...

So, it points to a apostrophe inside RegExp literal. But when I test that line only with your unit test, it passed successfully. It's very strange. Also exception said offset 107117, but that apostrophe is placed in 107002.

I will rename ckeditor.js to ckeditor.min.js, but the bug still exists.

Problem with CSS Reset

I was reluctant to post this as an issue, but it may just be one. I've been using Minify for a few years, and this is the first problem I've ever come across. It's possible (and maybe even likely) that the issue is on my end, but judging by the symptoms it may very well be something with Minify itself.

Using the latest version, I have reduced the issue down to a small block of CSS from Eric Meyer's reset:

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}

When this block is added, the stylesheet fails to load through Minify. When viewing the direct URL, the following error appears in Firefox:

The connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try again in a few moments.
* If you are unable to load any pages, check your computer's network connection.
* If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

Of course, it works once you remove the above CSS block. After realizing this, I tried to pin-point the problem, but it seems that there is no single point of failure. It seems that reducing the number of selectors will cause it to work again, but there is no particular selector (or quantity of selectors) that's causing it to break.

Please watch this video so you can see what I'm seeing: http://csnl.net/temp/minify.mov

It seems that the simple act of adding or removing CSS selectors shouldn't cause anything to break, so I'm not sure if this is something to do with Minify or something else on my end.

What do you make of this?

Main repo question

Hi, a question.
what is your main minify repository, the hosted on code.google or github?

Best regards.

mtime based cache id problems

currently if using groupsConfig, then cache id becames simply max(mtime) of all files.

so, the cache id will remain the same, if i add more files to the group having identical timestamp.

i guess there should be added * NUMBER_OF_FILES to avoid this problem

so i had in my groupsConfig.php:

  'l' => array(
      '/path/to/lazyload.js'
  ),

then url built with was:

  g=l&amp;1338376276

later i added one more file:

  'l' => array(
      '/path/to/uaft.js',
      '/path/to/lazyload.js'
  ),

and the url remained the same:

  g=l&amp;1338376276

as the files have identical timestamp:

$ ls -l --full uaft.js lazyload.js 
-rw-r--r-- 1 root root 1.3K 2012-05-30 14:11:16.000000000 +0300 lazyload.js
-rw-r--r-- 1 root root 1.7K 2012-05-30 14:11:16.000000000 +0300 uaft.js

expanding that timestamp:

$ LC_ALL=C php -r 'echo strftime("%c %z\n", 1338376276);'
Wed May 30 14:11:16 2012 +0300

Implement sourcemaps

Sourcemaps are the new hotness for debugging minified javascript. It would be cool to see that on this library, although it requires Base64 with VLQ. There are implementations of sourcemaps in the closure compiler

Bug compilation with bootstrap 3

Hello, For whatever reason there is a problem with minify, if bootstrap.css uses (bootstrap 3) from the Less compilation.

No notification but stylesheet not loaded

Broken JS minification

Trying to minify this:

/* http://example */
alert('success');

Returns:

/* 1 */ /* http://example.com */
/* 2 *| alert('success');

Commenting out the regexp added to Lines.php in d67feea fixes it to return the expected output:

/* 1 */ /* http://example.com */
/* 2 */ alert('success');

Trouble getting minify to work on dedicated server

I have no trouble getting min to work on my local environment, and localhost:8888/min/f=min/quick-test.css works fine.

I am trying to get this working on the 'dev' environment of my server... so I set up a subdomain at dev.example.com, and created a new web root at /dev_html/ instead of /public_html/. This all seems to be working though, because when I run echo $_SERVER['DOCUMENT_ROOT'], it works as expected. So I don't think the subdomain has anything to do with why this isn't working.

I am testing with an untouched version of min on my server, directly in my subdomain's document root, but when I test dev.mydomain.com/min/f=min/quick-test.css, I receive an Internal Server Error on the request.

Thanks for any help, Nick

Re-design cache invalidation around md5(content) instead of timestamp

Minify currently assumes new file content will arrive with a fresh mtime. This makes it fast, but misses file changes in some situations.

Essentially we want to monitor md5(content) of each source. This is relatively slower than checking timestamps, so we'll make up for it by giving the cache a max-age and only revalidating after that period. Nearly every request will be faster because we only have to check the cache's timestamp.

I think each cacheId (mapping to a URL) will have four files:

  • PT and GZ: plaintext and gzipped versions of the output, ready for readfile()
  • MD1: a file containing MD5s of each source.
  • MD2: a file containing the last time the MD5s were checked, and the ETag and Last-Modified headers to be sent if this file is fresh.

On each request, load MD2. If fresh, send the ETag/Last-Modified and the content (or 304). If MD2 is not fresh, check all sources against MD1, potentially regenerating all caches, or just up the timestamp in MD2.

This is fine if getting an MD5 is cheap, but some Minify configurations use non-files as sources, and we don't want to be fetching source every few seconds. Not sure how to deal with that.

Why does jsMinifier ignore type attribute for SCRIPT tags?

I can see in the comments of Minify_HTML that when a jsMinifier callback is specified, the type attribute for SCRIPT tags is ignored. Why not err on the side of caution, and ONLY run the callback for when type="text/javascript"?

I'm trying to hook up Minify's HTML minification to an application that sometimes uses a javascript templating engine (like mustache), so it has SCRIPT tags that contain HTML content - which causes JSMin to throw an uncaught exception.

Since all sorts of content might appear within a SCRIPT tag, at least if type="text/javascript" one could be reasonably assured that in fact it does only contain Javascript.

Cheers,
John

auto-minify MIME detect php

PHP support prepare content on before/after

Need:

  • Set hook get content auto_prepend_file
  • Detect mime type text/html and output minify content on auto_append_file
Directive Value
auto_append_file /var/www/end.php
auto_prepend_file /var/www/start.php

start.php

# ....
ob_start();

end.php

function compress_html($buf)
{
   include_once "minify/min/lib/Minify/HTML.php";
   return Minify_HTML::minify($buf);
}

foreach (headers_list() as $header) {
  if (preg_match('#Content-Type:\s+([\w/+]+)(;\s+charset=(\S+))?#is', $header, $match_mime))
  {
    switch (strtolower($match_mime[1]))
    {
      case "text/html":
         #
      break;
      case "text/css":
         #
      break;
      case "text/javascript":
         #
      break;
      default:
         #
      break;
    }
  }
}

if start hook ob_start(), not work Content-Type

deprecate md5

md5 was deprecated nearly a decade ago. However, it is still used as the only digest cryptographic tool.

Composer error

Hi there,

Since a few days, Composer is returning an error when running 'update' because the location of the GIT repository seems to have changed. Is it possible you could fix that with Packagist?

  [RuntimeException]                                                                                
  Failed to clone http://github.com/mrclay/minify.git via git, https and http protocols, aborting.  

  - git://github.com/mrclay/minify.git                                                              
    fatal: Not a git repository (or any of the parent directories): .git     

Race condition in Minify_Cache_File with locking

it's possible that Minify_Cache_File gets racy when two concurrent thread try to put something to cache. and it reports code error

so, one thread that gets error. first it can't open file (which it assumes exists), gets false from fopen, and passes that false to flock:

PHP Warning:  fopen(/tmp/concurrency_test_500): failed to open stream: No such file or directory in vendor/mrclay/minify/min/lib/Minify/Cache/File.php on line 101
PHP Stack trace:
PHP   1. {main}() htdocs/tests/session.php:0
PHP   2. Minify_Cache_File->store() htdocs/tests/session.php:15
PHP   3. Minify_Cache_File->fetch() vendor/mrclay/minify/min/lib/Minify/Cache/File.php:37
PHP   4. fopen() vendor/mrclay/minify/min/lib/Minify/Cache/File.php:101
FP OPEN FAILED!
PHP Warning:  flock() expects parameter 1 to be resource, boolean given in vendor/mrclay/minify/min/lib/Minify/Cache/File.php on line 106
PHP Stack trace:
PHP   1. {main}() htdocs/tests/session.php:0
PHP   2. Minify_Cache_File->store() htdocs/tests/session.php:15
PHP   3. Minify_Cache_File->fetch() vendor/mrclay/minify/min/lib/Minify/Cache/File.php:37
PHP   4. flock() vendor/mrclay/minify/min/lib/Minify/Cache/File.php:106

the problem appears when one thread updates cachefile, second thread updates cachefile, refetches cachefile to see if there's what it wrote, sees it's not, and unlinks the cachefile. so when third thread does the same, it opens file which is no longer there, gets the false and produces the second warning on flock() call

if ($this->_locking) {

  /**
    * Fetch the cached content
    *
    * @param string $id cache id (e.g. a filename)
    * 
    * @return string
    */
   public function fetch($id)
   {
       if ($this->_locking) {
           $fp = fopen($this->_path . '/' . $id, 'rb');
           flock($fp, LOCK_SH);
           $ret = stream_get_contents($fp);
           flock($fp, LOCK_UN);
           fclose($fp);
           return $ret;
       } else {
           return file_get_contents($this->_path . '/' . $id);
       }
   }

so perhaps just return false, when $fp = fopen() fails, this would match the behavior file_get_contents() does when it can't read a file.

and in more general fix, the locking should be used on a path that always exists (not unlink()'ed middle of action), i.e the dir containing the cachefile, or separate file for locking.

putting lock on cachedir, may affect two separate threads with different cachefile, which may create too many unwanted locks, so perhaps separate lockfile is better? or make it configurable?

my testcase involved shell script putting code run in background. and for sake of creating race at better rate, i made script to write different contents for each thread. ideally (in production where it happened) the cache value did not vary that much indeed.

<?php
require_once dirname(__FILE__) . '/../../vendor/autoload.php';

define('CACHE_ID', 'concurrency_test_' . posix_getuid());
define('CACHE_DIR', sys_get_temp_dir());
$cache = new Minify_Cache_File(CACHE_DIR, true);
if ($cache->isValid(CACHE_ID, 0)) {
    $session_id = trim($cache->fetch(CACHE_ID));
}
$value = 'value' . rand(1, 10000);
$cache->store(CACHE_ID, $value);

and the shell script to reproduce:

$ rm -f /tmp/concurrency_test_500 && for a in $(seq 1 50); do php session.php $a &  done

Forcing whitespace collapses only with HTML

Is there a way to make the HTML minifier focus on collapsing whitespace only? And of course not do it for any element that is whitespace sensitive like pre and textarea.

This is because some JS frameworks like AngularJS can have significant comments that indicate a directive.

Also is this minifier tolerant of malformed html?

iOS 7 Safari issue

Hi, I've got a problem with brand new iOS 7 Safari browser. It doesn't want to load minified files like CSS and maybe JS too through your Minify module :( It's tricky to debug it on phone. But in Chrome on iOS 7 is everything OK. Thanks for respond. I'm gonna minify it by hand :D

Minify XML?

Can we safely use Minify_HTML::minify($xml, array('xhtml' => true)); in order to minify any xml content ?

CSS Minify::combine() creating a lot of random new lines

This issue might be cosmetic only, but maybe it might have some bigger consequences on other browsers

Please check
http://www.skimbl.com/css/cache/skimbl.1308290908.css (ignoring the first font declarations)
the result of Minify::combine()


ul, ul
li{list-style:none}

//later

.content
h2{margin:6px
0}

// more
img.thumb,.missing-image{float:left;display:block;margin:0
10px 0 0;border:1px
solid #E5E5E5;-moz-box-shadow:1px 1px 0px #F0F0F0;-webkit-box-shadow:1px 1px 0px #F0F0F0;box-shadow:1px 1px 0px #F0F0F0}

It don't expect the whole output to be one line only, but the new lines seem quite random, although it probably isn't

closure-compiler does seem to want to pass test_all

Been struggling with getting this to pass the test-all. I wonder if my server is not allowing..

Warning: file_get_contents(http://closure-compiler.appspot.com/compile): failed to open stream: Connection timed out in /var/www/html/site/min/lib/Minify/JS/ClosureCompiler.php on line 87

Fatal error: Uncaught exception 'Minify_JS_ClosureCompiler_Exception' with message 'No HTTP response from server' in /var/www/html/site/min/lib/Minify/JS/ClosureCompiler.php:104
Stack trace:
#0 /var/www/html/site/min/lib/Minify/JS/ClosureCompiler.php(56): Minify_JS_ClosureCompiler->_getResponse('js_code=%0A%28f...')
#1 /var/www/html/site/min/lib/Minify/JS/ClosureCompiler.php(29): Minify_JS_ClosureCompiler->min('?(function (win...')
#2 /var/www/html/site/min_unit_tests/test_Minify_JS_ClosureCompiler.php(18): Minify_JS_ClosureCompiler::minify('?(function (win...')
#3 /var/www/html/site/min_unit_tests/test_Minify_JS_ClosureCompiler.php(47): test_Minify_JS_ClosureCompiler()
#4 /var/www/html/site/min_unit_tests/test_all.php(12): require('/var/www/html/s...')
#5 {main}

thrown in /var/www/html/site/min/lib/Minify/JS/ClosureCompiler.php on line 104

Add image base64 option

If possible, it could be useful to enable an option to convert CSS background image to its base64 version to speed up CSS and site loading

Closure compiler fails when allow_url_fopen=0

Using version 2.1.4. I tried to use the experimental closure compiler by adding this line to my config file:

$min_serveOptions['minifiers']['application/x-javascript'] = array('Minify_JS_ClosureCompiler', 'minify');

But, unfortunately I get the following errors:

Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /path/to/min/lib/Minify/JS/ClosureCompiler.php on line 85
Warning: file_get_contents(http://closure-compiler.appspot.com/compile) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /path/to/min/lib/Minify/JS/ClosureCompiler.php on line 85
Warning: Cannot modify header information - headers already sent by (output started at /path/to/min/lib/Minify/JS/ClosureCompiler.php:85) in /path/to/min/lib/Minify.php on line 439
Warning: Cannot modify header information - headers already sent by (output started at /path/to/min/lib/Minify/JS/ClosureCompiler.php:85) in /path/to/min/lib/Minify.php on line 440

500 Internal Server Error

Please see http://code.google.com/p/minify/wiki/Debugging.

I realize that it would probably work if we enabled allow_url_fopen, but it would be nice if Minify would gracefully fall back to another method, perhaps cURL.

Prevent concurrent minify processing

We've been using minify in production for a while. Recently when a stylesheet is updated under high load many requests race to minify the stylesheet causing 100% CPU usage on all cores.

There's a similar issue at #266

but this seems to be missing in current releases

IcoMoon Icon font won't minify (CSS)

Hi guys, so i went here and grabed the IconMoon Icon Font. You get a CSS file with all the classes for the icons and the standard font-face font file. Then i tried to minify it using "minify" and it just keept on loading and loading the minifed css file untill after a few seconds it just stops and no css was loaded?

What could be the problem to this?

wildcard character seems not to work with CLI

Hi,

I am using the CLI tool to minify and combine js files.

So I am typing in the cmd:

php tools\minifier\min_extras\cli\minify.php -o tools\myproject-minified.js -t js myproject/js/*.js

as a result I have a file telling me that '*.js' does not exist.

The path is not wrong because if I replace *.js by an existing js file, it is working.

In the CLI help, it seems that we can use the * charcater to select all files in a specifc directory.
Writing that, I have the impression that I misunderstood something from the CLI help and *.js stands for 'type-here-your-js-filename.js'

So the question is, is '*.js' supposed to find all js files from the specific directory ?

I am using minify 2.1.7 on Windows with PHP 5.3.9

Thank you in advance for your answer

Multiline strings break debug mode

If you have a multiline string in javascript such as

var x = "Test content
More content
And content";

The line numbers will be added into this multiline string

/* 100 / var x = "Test content
/
101 / More content
/
102 */ And content"

As suggested in issue #46 a quick fix may be to just allow an option disabling line numbers in debug mode.

Debug mode broken by strings with multiline comment tokens and multiline strings

Looks like there is a hack for a more simple case https://github.com/mrclay/minify/blob/master/min/lib/Minify/Lines.php#L45
But that don't help with this problem globally. For example wysibb has lines of code like

    bbClose:"[/*]\n[/list]",

And /* in it is treated as a commentary start.

I honestly have no idea how this can be fixed, except with partially implementing Ecmascript parser in PHP.
Maybe you can make option for disabling line numbers in debug mode altogether? Sometimes you just need your code unfolded to try and add some breakpoints.

PSR-0 without set_include_path

Would be great that the minify module would follow the PSR-0 and be able to be autoloaded in frameworks that support that. the naming convention on the files already exist, just the explicit require/require_once inside the files that make autoloaders choke

Notice: Undefined index: HTTP_USER_AGENT in /path/to/min/lib/HTTP/Encoder.php on 321

Backtrace:

/path/to/min/lib/HTTP/Encoder.php (line 321)
/path/to/min/lib/Minify.php (line 226) HTTP_Encoder::isBuggyIe()
/path/to/min/index.php (line 66) Minify::serve()

$_SERVER:

Array
(
    [REDIRECT_VERSIONED_FILE] => 1
    [REDIRECT_STATUS] => 200
    [HTTP_HOST] => myhost.com
    [HTTP_ACCEPT] => */*
    [HTTP_CONNECTION] => close
    [PATH] => /sbin:/usr/sbin:/bin:/usr/bin
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache/2.2.15 (Red Hat)
    [SERVER_NAME] => myhost.com
    [SERVER_ADDR] => ###.###.###.###
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => ###.###.###.###
    [DOCUMENT_ROOT] => /path/to/files/
    [SERVER_ADMIN] => [email protected]
    [SCRIPT_FILENAME] => /path/to/file.php
    [REMOTE_PORT] => 18133
    [REDIRECT_URL] => /css/myfile.v25.css
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.0
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /css/myfile.v25.css
    [SCRIPT_NAME] => /path/to/file.php
    [PHP_SELF] => /path/to/file.php
    [REQUEST_TIME] => 1318458030
)

Make compatible with composer and add to packagist

It would be great if this project could be added to packagist as a composer package.

It's very easy and requires very little maintenance, you create a composer.json file and it's ready to be added to http://packagist.org. I'd be happy to help out, if you want me to I can fork and send a PR with the necessary changes.

disable rewriting of css uri's is not working

According to docs at http://code.google.com/p/minify/wiki/UriRewriting

$min_serveOptions['rewriteCssUris'] = false;

I should be able to add the above to my configuration file and it will disable uri rewriting. The reason I want to disable it, is because I don't need it. All my css/js files are in one folder and not nested at all. It is rewriting the urls. For example

Example:

minify/min_extras/cli/minify.php -o ../css/all.css ../css/phppos.css ../css/menubar.css ../css/general.css ../css/popupbox.css ../css/register.css ../css/receipt.css ../css/reports.css ../css/tables.css ../css/thickbox.css ../css/datepicker.css ../css/editsale.css ../css/footer.css ../css/css3.css ../css/jquery-ui-1.8.14.custom.css ../css/jquery.loadmask.css ../css/jquery.ui.all.css ../css/paginate.css

Before:

background-image: url("../images/header/header_empty.png");

After:

background-image:url("./header/header_empty.png");

Builder JS breaks under jQuery 1.9 due to use of obsolete $.browser

This code on line 244 of builder/_index.js breaks under jQuery 1.9+:

if ($.browser.msie) {
    $('#getBm p:last').append(' Sorry, not supported in MSIE!');
}

$.browser is no longer available; use $.support instead. Giving up on IE entirely is also a bit unsporting; better to give up on the feature that old IE versions are lacking since IE9 and 10 are not so bad, for example using $support.boxModel.

wrong CSS rewrite when developing in subdirectory

When using a subdirectory like C:\Users\Webdev\www\app, and setting the documentRoot to C:\Users\Webdev\www\app, but the URL is accessed through http://localhost/app/, the rewrites for http://localhost/app/images/ point to http://localhost/images which is wrong. Create a option so the rewrite url can be prepended.

XSS

The method serve, line 312, in Minify.php does not properly validate malicious input. As a result, one is able to cause a multitude of injection attacks.

JSMin: Unterminated String at byte

I have a problem minifying Plupload v2.0 (plupload.full.min.js) with JSMin::minify().

The error says:
JSMin: Unterminated String at byte 64434: "===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)' in /Minify/JSMin.php:203

What can I do. Is there a lint problems fixer or something?

Edit: Works fine on a Windows system but the error above still appears on a Debian system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.