Dancer2::Plugin::Minify - Minify HTML, JavaScript and CSS
version 0.002
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; }'); }
This Dancer2 plugin is a wrapper for HTML::Packer, JavaScript::Packer and CSS::Packer.
Synopsis: minify( $type, $text, $args )
minify( $type, $text, $args )
Minifies the content of $text and returns it.
$text
$html = minify(html => $html, { });
Hint: $args is a HashRef.
$args
$type must be one of:
$type
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.
Minifies CSS. Allowed options for $args:
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.
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.
David Zurborg <zurborg@cpan.org>
This software is Copyright (c) 2016 by David Zurborg.
This is free software, licensed under:
The ISC License
To install Dancer2::Plugin::Minify, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Plugin::Minify
CPAN shell
perl -MCPAN -e shell install Dancer2::Plugin::Minify
For more information on module installation, please visit the detailed CPAN module installation guide.