NAME
Dancer2::Plugin::Minify - Minify HTML, JavaScript and CSS
VERSION
version 0.002
SYNOPSIS
use Dancer2;
use Dancer::Plugin::Minify;
get '/index.html' => sub {
minify(html => '<bloated>HTML</bloated>');
}
get '/index.js' => sub {
minify(js => 'function bloated() { }');
}
get '/index.css' => sub {
minify(css => 'bloated { display: none; }');
}
DESCRIPTION
This Dancer2 plugin is a wrapper for HTML::Packer, JavaScript::Packer and CSS::Packer.
FUNCTIONS
minify
Synopsis: minify( $type, $text, $args )
Minifies the content of $text
and returns it.
$html = minify(html => $html, { });
Hint: $args
is a HashRef.
$type
must be one of:
html
Minifies HTML. Allowed options for
$args
:remove_comments
Remove all HTML comments. Defaults to true.
remove_newlines
Remove ALL newlines. Defaults to true.
js_compress
Compress level for JavaScript. Defaults to best.
css_compress
Compress level for CSS. Defaults to minify.
See also HTML::Packer.
js
Minifies JavaScript. Allowed options for
$args
:compress
Compress level. Defaults to best.
Hint: the global keyword in the plugin settings is named js_compress.
See also JavaScript::Packer.
js
Minifies CSS. Allowed options for
$args
:compress
Compress level. Defaults to minify.
Hint: the global keyword in the plugin settings is named css_compress.
See also CSS::Packer.
All mentioned keywords above also apply to the plugin settings in your Dancer2 environment.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/zurborg/libdancer2-plugin-minify-perl/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
David Zurborg <zurborg@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2016 by David Zurborg.
This is free software, licensed under:
The ISC License