HTML::Packer(3pm)

HTML::Packer3pm

Another html code cleaner

Usage

    use HTML::Packer;
    my $packer = HTML::Packer->init();
    $packer->minify( $scalarref, $opts );

To return a scalar without changing the input simply use (e.g. example 2):

    my $ret = $packer->minify( $scalarref, $opts );

For backward compatibility it is still possible to call 'minify' as a function:

    HTML::Packer::minify( $scalarref, $opts );

First argument must be a scalarref of HTML-Code. Second argument must be a hashref of options. Possible options are

remove_comments

HTML-Comments will be removed if 'remove_comments' has a true value. Comments starting with "<!--#", "<!--[" or "<!-- google_ad_section_" will be preserved unless 'remove_comments_aggressive' has a true value.

remove_comments_aggressive

See 'remove_comments'.

remove_newlines

ALL newlines will be removed if 'remove_newlines' has a true value.

do_javascript

Defines compression level for javascript. Possible values are 'clean', 'obfuscate', 'shrink' and 'best'. Default is no compression for javascript. This option only takes effect if JavaScript::Packer is installed.

do_stylesheet

Defines compression level for CSS. Possible values are 'minify' and 'pretty'. Default is no compression for CSS. This option only takes effect if CSS::Packer is installed.

do_csp

Defines hash algorithm for "Content-Security-Policy", or CSP, hashes of embedded "<script>" and "<style>" tags.

Allowed values are 'sha256', 'sha384', 'sha512'.

It may be left blank or set to a Perl false value to indicate that hashes should not be calculated, if performance is a concern.

no_compress_comment

If not set to a true value it is allowed to set a HTML comment that prevents the input being packed.

    <!-- HTML::Packer _no_compress_ -->

Is not set by default.

html5

If set to a true value closing slashes will be removed from void elements.

csp

If "do_csp" is set to 'sha256', returns a hash that looks like this:

    (
        'script-src' => [qw( sha256-...= sha256-...= )],
        'style-src'  => [qw( sha256-...= sha256-...= )],
    )

with each element of the "ARRAY"refs containing a CSP-friendly hash for a "<script>" or "<style>" tag.

Version

Version 2.11

Overview

A HTML Compressor.

Support

You can find documentation for this module with the perldoc command.

perldoc HTML::Packer

Releases

8 releases since Debian 6.0 (Squeeze); the text changed 6 times.

  1. 6.0
  2. 7–8
  3. 9
  4. 10
  5. 11
  6. 12
  7. 13

Author

Merten Falk, "<nevesenin at cpan.org>". Now maintained by Lee Johnson (LEEJO) with contributions from:

        Alexander Krizhanovsky <[email protected]>
        Bas Bloemsaat <[email protected]>
        girst <[email protected]>
        Ankit Pati (ANKITPATI) <[email protected]>

Bugs

Please report any bugs or feature requests through the web interface at <https://github.com/leejo/html-packer-perl/issues>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

From libhtml-packer-perl 2.110000-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.