Catalyst::View::JavaScript - Cache and/or compress JavaScript output


version 0.995


This module fetches JavaScript either from the stash or from $c->output. By default the JavaScript code is read from $c->stash->{js} and compressed. The content type is set to text/javascript.

By default this view will not compress and/or cache if your application is in the debug mode.



If $c is able to cache (i. e. if $c->can('cache')) the value of cache is used as key to cache the JavaScript output. This method returns the view so you can invoke it like this:

  $c->detach( $c->view('JavaScript')->cache('unique-cache-key') );


Set this to a true value to enable compression of the code. See JavaScript::Minifier::XS for more information on how this minification works. Defaults to 1.

This string will be displayed on the top of the output enclosed in a commentary tag.


If you set the debug flag on your application caching and compressing is disabled. Defaults to 1.


If this is set to a true value this module fetches the JavaScript code from $c->output and ignores the value of "stash". Defaults to 0.


This module looks in the stash for this value for JavaScript if "stash" is enabled. Defaults to js.


Set this to a true value if the JavaScript code is on the stash. Set the stash value with "key". Defaults to 1.


Moritz Onken, <onken at>


Please report any bugs or feature requests to bug-catalyst-view-javascript at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Copyright 2009 Moritz Onken, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.