Integration with HTML::Mason 

<%method add_js_file>
<%perl>
    my($file) = @_ or return;
    $file = "/js/$file" unless $file =~ {/};
    if($ENV{SERVER_TYPE} =~ /dev/) {
        $file =~ s{[.](?:min|pack)[.]js$}{.js};
    }
    my $files = $m->notes('js_files') || [];
    if(not grep { $_ eq $file } @$files) {
        push @$files, $file;
    }
    $m->notes('js_files', $files);
</%perl>\
</%method>

<%method add_js_snippet>
<%perl>
    my($code) = @_ or return;
    my $snippets = $m->notes('js_snippets') || [];
    push @$snippets, $code;
    $m->notes('js_snippets', $snippets);
</%perl>\
</%method>

<%method add_css_file>
<%perl>
    my($file) = @_ or return;
    $file = "/style/$file" unless $file =~ m{/};
    my $files = $m->notes('css_files') || [];
    if(not grep { $_ eq $file } @$files) {
        push @$files, $file;
    }
    $m->notes('css_files', $files);
</%perl>\
</%method>