Publish time merging is good idea but sometimes say page "A" needs 'a.js' and 'b.js' whereas page "B" needs 'a.js' and 'c.js' and there can many such dynamic combinations. Doing this check at build time and then grouping is sometimes very hectic.
What if grouping happens on the fly for required resources and with one HTTP request like this...
<script language="JavaScript" src="/appContext/js/a,./subdir/b.js"></script>
WebUtilities library (for J2EE) does exactly same and helps with many other front end optimizations.
- Minimizing HTTP requests
- Minifying JS,CSS files
- Minifying inline JS, CSS snipped (custom tag)
- Leveraging browser caching (Expires, Cache-Control)
- Server side caching (until resource changes)
- Early setting charset etc.
Here is the link. Have look in case you find it useful.
http://code.google.com/p/webutilities/