NAME

App::ZofCMS::Plugin::JavaScriptMinifier - plugin for minifying JavaScript files

SYNOPSIS

In your ZofCMS Template or Main Config File:

plugins => [
    qw/JavaScriptMinifier/,
],

plug_js_minifier => {
    file => 'main.js',
},

Now, this page can be linked into your document as a JavaScript file (it will be minified)

DESCRIPTION

The module is a plugin for App::ZofCMS that provides means to send minified JavaScript files.

This documentation assumes you've read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template

WTF IS MINIFIED?

Minified means that all the useless stuff (which means whitespace, etc) will be stripped off the JavaScript file to save a few bytes. See JavaScript::Minifier for more info.

FIRST-LEVEL ZofCMS TEMPLATE AND MAIN CONFIG FILE KEYS

plugins

plugins => [
    qw/JavaScriptMinifier/,
],

Mandatory. You need to include the plugin to the list of plugins to execute.

plug_js_minifier

plug_js_minifier => {
    file        => 'main.js',
    auto_output => 1, # default value
    cache       => 1, # default value
},

plug_js_minifier => sub {
    my ( $t, $q, $config ) = @_;
    return {
        file        => 'main.js',
        auto_output => 1,
        cache       => 1,
    };
},

Mandatory. Takes a hashref or a subref as a value. If subref is specified, its return value will be assigned to plug_js_minifier as if it was already there. If sub returns an undef, then plugin will stop further processing. The @_ of the subref will contain (in that order): ZofCMS Tempalate hashref, query parameters hashref and App::ZofCMS::Config object. Individual keys can be set in both Main Config File and ZofCMS Template, if the same key set in both, the value in ZofCMS Template will take precedence. The following keys/values are accepted:

file

plug_js_minifier => {
    file        => 'main.js',
}

Mandatory. Takes a string as an argument that specifies the name of the JavaScript file to minify. The filename is relative to index.pl file.

cache

plug_js_minifier => {
    file        => 'main.js',
    cache       => 1,
},

Optional. Takes either true or false values. When set to a true value the plugin will send out an HTTP Expires header that will say that this content expries in like 2038, thus set this option to a false value while still developing your JavaScript. This argument has no effect when auto_output (see below) is turned off (set to a false value). Defaults to: 1

auto_output

plug_js_minifier => {
    file        => 'main.js',
    auto_output => 1,
},

Optional. Takes either true or false values. When set to a true value, plugin will automatically send text/javascript Content-type header (along with Expires header if cache argument is set to a true value), output the minified JavaScript file and exit(). Otherwise, the minified JavaScript file will be put into $t->{t}{plug_js_minifier} where $t is ZofCMS Template hashref and you can do whatever you want with it. Defaults to: 1

REPOSITORY

Fork this module on GitHub: https://github.com/zoffixznet/App-ZofCMS

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/App-ZofCMS/issues

If you can't access GitHub, you can email your request to bug-App-ZofCMS at rt.cpan.org

AUTHOR

Zoffix Znet <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/)

LICENSE

You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.