Let's say my page structure is :

```
1. one.html :
   includes ->   a.js , b.js , c.js ,d.js

2. two.html :
   includes ->   a.js , b.js,  x.js, y.js, z.js

3. three.html :
   includes ->   a.js , b.js, s.js,  x.js, y.js

```

and so on.
Some pages are more visited than others, say 3 pages contribute 99% of all page views of the website.

I am looking for a solution to:

i) Combine and minimize files in groups which can be included in the pages.

ii) Has some logic to map files names of the group, to final combined file name.

iii) Includes a minifier like Google Closure compiler / YUI compressor.

One solution I have looked at is:
[PHP minify](https://github.com/mrclay/minify)

which does most of it. However it has following drawbacks for me:

i) I would be hosting my static combined files on a CDN server,not on same web server hosting PHP minify, hence PHP minify's logic to server files by group name does not work for me.

ii) PHP Minify uses PHP CGI to process and serve the scripts, whereas I would want my minified content to be served directly from the CDN server.

Does PHP Minify have some functions to map group name to combined file name, which I can use in my webpage to directly set CDN path of the combined JS file. eg

```
<?php
  $groupName = array("onePage" => array('a.js','b.js','c.js','d.js');
?>

<script type="text/javascript" src="http://www.MYSTATICSERVER.com/js/<?php getMergedFileName($groupName)"></script>

```

Rather than calling PHP Minify's PHP script to get files of a group, which is
actually a PHP page call,which then serves the javascript content from previously
generated files:

```
<script type="text/javascript" src="http://www.MYWEBSERVER.com/min/?g=onePage" ></script>

```

( I agree most of this is doable by combining different solutions with custom deployment scripts and minifying tools eg ANT,FABRIC + YUICompressor/ClosureCompiler, but I am looking for a well developed configurable solution that I might have missed )