ericmckean / minify

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

Allow combination of "g" & "f" #86

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Minify version: 2.1.1

In the code i have been using, there is a certain subset of files which is
static (e.g. jQuery, basic css etc.) depending on functionality of the
generated page, i want to extend this by adding specific CSS or JS files.

I've tried to do
/min/?g=css&f=/css/extra.css

but it only takes the "group" part. It would be really cool if those 2
could be combined.

Original issue reported on code.google.com by gilles0...@gmail.com on 4 Feb 2009 at 10:00

GoogleCodeExporter commented 9 years ago
Makes sense to me and should be easy.

Multiple groups might be nice, too: /min/?g=grp1,grp2

Original comment by mrclay....@gmail.com on 4 Feb 2009 at 1:09

GoogleCodeExporter commented 9 years ago
A comment on this request: it might not be a very good move regarding 
performance.

Say you have groups for JS files and CSS files common to all pages in the 
website.
Then on a "Sign in" page you want to call an additional JS script that does form
validation just for that page.

If you call "?g=js-common" on the homepage, and then
"?g=js-common&f=/js/signin-validation.js" on the sign-in page, then from the 
browser
perspective you have two totally different files: A and B. And A could be 80 KB,
while B would be 85 KB. Even though those two files are very similar (A is a 
subset
of B), the browser still has to load 165 KB total for a user going from the 
Home page
to the Sign in page.

Another solution would be to call the additionnal scripts separately:

<script src="min/?g=js-common"></script>
<script src="min/?f=/js/signin-validation.js"></script>

You get two server hits, one is 80 KB and the other is 5 KB. You save 80 KB of
unnecessary downloads. Is that one additionnal server hit a problem? I don't 
think
so. What's more, if the user went from the Home page to the Sign in page, then 
you have:

- one 80 KB download on the Home page;
- one 5 KB download on the Sign in page.

Instead of:

- One 80 KB download on the Home page;
- one 85 KB download on the Sign in page.

Here, i'm not saying this request or the multiple groups idea shouldn't be
implemented. But in some (many? most?) cases using this feature could be a bad 
idea
actually.

Original comment by fverschelde on 26 Apr 2009 at 9:41

GoogleCodeExporter commented 9 years ago
@fverschelde: You're completely right, but Minify can already be misused this 
way; 
we have to assume that people will use Minify wisely depending on the structure 
of 
their site, how visitors surf it, etc.

That said, this feature is pretty low on my priority list and may be a lot more 
messy than I originally thought.

Original comment by mrclay....@gmail.com on 1 May 2009 at 6:01

GoogleCodeExporter commented 9 years ago
Just because it can promote bad practice (for unexperienced users) it does not 
mean 
it can't be usefull. The example you posted is in my eyes just bad practice. 
What i 
am just trying to say is that it is ultimately the responsibility of the coder 
to 
optimize their calls to minify, not the author of minify to prevent you from 
doing 
that.

Original comment by gilles0...@gmail.com on 8 Jun 2009 at 6:33

GoogleCodeExporter commented 9 years ago
This allows the 2.1.3 release to serve both multiple groups (comma-separated 
keys) 
and files in the same request. Caveats from the docs:

Caveat: Groups always come before files, but the groups are ordered as 
requested. 
E.g.
/f=file.js&g=js1,js2 == /g=js1,js2&f=file.js != /g=js2,js1&f=file.js

Caveat: If JS group(s) are specified, the method will still allow you to add 
CSS 
files and vice-versa. E.g.:
/g=js1,js2&f=site.css => Minify will try to process site.css through the 
Javascript 
minifier, possibly causing an exception.

Original comment by mrclay....@gmail.com on 13 Oct 2009 at 12:15

Attachments:

GoogleCodeExporter commented 9 years ago
Trunk fixed in R381

Original comment by mrclay....@gmail.com on 13 Oct 2009 at 12:57

GoogleCodeExporter commented 9 years ago
FYI, this is coming in 2.1.4

Original comment by mrclay....@gmail.com on 17 May 2010 at 4:31

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:59