I've been playing with the very nice YSlow firefox plugin recently, while doing some front-end optimisation on a Catalyst web project.
Turns out - as is often the case - there's a very nice packaged solution on CPAN.
There's also a Catalyst::Plugin::Assets module to facilitate using File::Assets from Catalyst.
I use Mason for my Catalyst views (I prefer using perl in my views rather than having another mini-language to learn) and so use this as follows.
First, you have to configure Catalyst::Plugin::Assets in your project config file (e.g. $PROJECT_HOME/project.yml):
Plugin::Assets: path: /static output_path: build/ minify: 1
%# in my person view <%attr> js => [ 'jquery.color.js', 'person.js' ] css => 'person.css' </%attr>
Then in my top-level autohandler, I include both global and per-page assets like this:
Then, elsewhere in the autohandler, you add an exported link at the appropriate point in the page:
This generates a link something like the following (wrapped here):
Beautiful, easy, maintainable.