ericmckean / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Minify should not error if one file is missing #169

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Minify version: 2.1.3
PHP version: 5.2.9

I really like minify and it is pretty inpressive how many request and KB 
you can save with so little extra work. But one thing doesn't work as good 
as it could do.

If you use the functionality to combine diffrent files to one JS file by 
using the query syntax 
http://example.com/min/f=scriptname.js,scriptname2.js and one of the files 
is missing on the server, the whole minify process will fail.

The result is that if you have let's say 10 JS files and only one is 
missing or misspelled ALL JS files won't be loaded.

It would be nice if you could check for file_exists() to catch that error. 
Sure I could do that myself as I already have all JA files to combine in an 
array but I think many users might have the same problem and as it was not 
so easy for me to find the issue it would be a big improvement to minify.

Another problem I had with grouping files was the 
$min_serveOptions['minApp']['maxFiles'] option which I haven't found in 
your online examples and as soon as I addded more than 10 files the minify 
process failed but without a understanable notice of what has failed. It 
might be a good idea to responde a file with a 404 in the header status but 
with a debugging message to inform the developer what has failed (but keep 
the IE 404 bug in mind: http://www.404-error-page.com/404-error-page-too-
short-problem-microsoft-ie.shtml)

But beside those issues the minify just works perfectly!

Original issue reported on code.google.com by bernhard...@gmail.com on 9 Apr 2010 at 11:11

GoogleCodeExporter commented 9 years ago

// As soon as I added more than 10 files the minify 
process failed but without a understandable notice of what has failed //

I'm having the same problem. I can't add more than 10 files. It's says 
something like
bad request ...

Error message :

HTTP/1.0 400 Bad Request

What is it supposed to mean? Can't we combine more than 10 files?

Regards,
Kathees

Original comment by katheesk...@gmail.com on 22 Apr 2010 at 6:34

GoogleCodeExporter commented 9 years ago

Got it guys! In the config.php (Inside your minify folder) you can find 
following line

$min_serveOptions['minApp']['maxFiles'] = 10;

This shows maximum number of files. If you want to use more than that all you 
have to
do is increase the number.

I'm very new to minify. Just trying use it in our application. So don't know we 
will
encounter any performance or whatever issues if we do that. May be someone can 
point
out???

Original comment by katheesk...@gmail.com on 22 Apr 2010 at 6:39

GoogleCodeExporter commented 9 years ago
I already mentioned the maxFiles variable in my post. But I don't see any need 
of 
such a function. It only leads to a failure if you doesn't know about it. And 
the 
error file doesn't contain any useful information about the error, so you 
cannot 
find out what was going wrong.

The bigger issue is the one I mentioned first. If a file is missing you want to 
group, the whole group will fail which will in the worst case results in zero 
JS 
and zero CSS on your page. That really is a big issue for me because it is very 
likely, that a file might be missing or missspelled or renamed.

@katheeskumar: We could improve the load speed and overall performance a lot 
using 
the group funtionality. And as Google takes the speed of a website in 
consideration 
when calculating the ranking, you should really give it a try. It is very easy 
to 
integrate (if use r.g. use the simple query style links) and it saves a lot of 
traffic and HTTP requests.

Original comment by bernhard...@gmail.com on 22 Apr 2010 at 10:23

GoogleCodeExporter commented 9 years ago
I'll remove maxFiles in the next release (not real soon).

For missing files, what I could do is prepend the output with:

/* ATTENTION: Minify could not find /path/to/file1.js */
/* ATTENTION: Minify could not find /path/to/file2.js */

In detail, missing files would cause 1 Minify_Source object to be the first 
source.
It would always have the same ID (to prevent poisoning the cache with lots of 
bad
URLs) and have the message about as its content.

@bernhardkau: I wouldn't put too much fail in Groups being tremendously faster. 
PHP
certainly does less work (and w/ cleaner URLs), but I've never ABed the 
performance
difference.

Original comment by mrclay....@gmail.com on 22 Apr 2010 at 5:50

GoogleCodeExporter commented 9 years ago
2.1.4 beta has this feature. 
http://code.google.com/p/minify/downloads/detail?name=minify_2.1.4_beta.zip

Original comment by mrclay....@gmail.com on 8 Jul 2010 at 4:56

GoogleCodeExporter commented 9 years ago
Hi all,

Thanks for the beta fix - it is a much better approach just reporting the 
missing files.  In my case for instance, when I upload a quick fix to our site 
during the upload process somebody may be making the request for the file at 
the same time, and it's better to see a slightly broken page rather than a 
completely useless page.

More importantly, I noticed that this fix only applies to individual files - it 
still failes completely if a group contains missing files?

in my groupsConfig.php:

 array( 'js_puntersparadise' => array('//js/jquery-1.3.2.min.js','//js/missingfile.js'));

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

Please help!

Original comment by Luc.Pett...@gmail.com on 26 Jul 2010 at 12:07

GoogleCodeExporter commented 9 years ago
@Luc, I should be able to apply the fix to group files as well.

Original comment by mrclay....@gmail.com on 26 Jul 2010 at 1:28

GoogleCodeExporter commented 9 years ago
Thank-you!  I've been going through the code but can't seem to find out how to 
fix it.  Line 83 of Groups.php seems to be where it was already applied, but 
for some reason it doesn't work?

Original comment by Luc.Pett...@gmail.com on 26 Jul 2010 at 2:01

GoogleCodeExporter commented 9 years ago
The controller is 
http://code.google.com/p/minify/source/browse/branches/2.1.4/min/lib/Minify/Cont
roller/MinApp.php
Line 139 has the check in the f= option. I need similar code at line 72.

Original comment by mrclay....@gmail.com on 26 Jul 2010 at 2:09

GoogleCodeExporter commented 9 years ago
Thank-you!  It worked for me.  I'm pretty sure i've done a really dodgie hack 
because I have no idea what I'm doing, but it works now.  Attached is the new 
file.

Original comment by Luc.Pett...@gmail.com on 26 Jul 2010 at 2:36

Attachments:

GoogleCodeExporter commented 9 years ago
In git master c8e903e

Original comment by mrclay....@gmail.com on 4 Sep 2011 at 1:11