HTML::Packer(3pm)
π HTML::Packer π
okay so bestie, you know how your HTML is out here looking like it just rolled out of bed? this is <pink>HTML::Packer</pink>, a.k.a. Another HTML code cleaner, and it's literally here to give your markup a glow-up. it's the HTML::Packer page from the User Contributed Perl Documentation, section 3pm, and we're gonna walk through it together, fr fr.
Version: 2.11 β yes queen, current.
β¨ NAME β¨
HTML::Packer β Another HTML code cleaner π§Ήβ¨
πΈ VERSION πΈ
Version 2.11
π¦ DESCRIPTION π¦
A HTML Compressor. that's it, that's the whole vibe check. it takes your HTML and squishes it down. iconic. π
π SYNOPSIS π
use HTML::Packer;
my $packer = HTML::Packer->init();
$packer->minify( $scalarref, $opts );
so to return a scalar without changing the input, you literally just do this (example 2, iykyk):
my $ret = $packer->minify( $scalarref, $opts );
and for backward compatibility β because we respect our elders β it is still possible to call minify as a function:
HTML::Packer::minify( $scalarref, $opts );
the first argument must be a scalarref of HTML-Code. the second argument must be a hashref of options. and the possible options areβ¦ bestie, sit down, we're going through all of them π
β¨ OPTIONS β¨
remove_commentsβ HTML-Comments get removed ifremove_commentshas a true value. BUT. not me protecting the special ones π β comments starting with"<!--#","<!--["or"<!-- google_ad_section_"will be preserved unlessremove_comments_aggressivehas a true value. so those little guys are safeβ¦ for now.remove_comments_aggressiveβ seeremove_comments. (yeah, it's giving "read the other one" but that's genuinely what it says. go look up there π)remove_newlinesβ ALL newlines will be removed ifremove_newlineshas a true value. all of them. every last one. no cap. πdo_javascriptβ defines the compression level for javascript. possible values are'clean','obfuscate','shrink'and'best'. default is no compression for javascript. β οΈ this option only takes effect ifJavaScript::Packeris installed. like, it needs the friend to show up to the party, otherwise nothing happens.do_stylesheetβ defines the compression level for CSS. possible values are'minify'and'pretty'. default is no compression for CSS. β οΈ same deal: this option only takes effect ifCSS::Packeris installed. slay, but conditional.do_cspβ defines the 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. (mood, honestly β sometimes we just don't have the energy π )
no_compress_commentβ if not set to a true value, it is allowed to set a HTML comment that prevents the input from being packed:
<!-- HTML::Packer _no_compress_ -->
is not set by default. so it's off unless you turn it on, bestie.
html5β if set to a true value, closing slashes will be removed from void elements. periodt. β¨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. cute, tidy, cryptographically valid. π
π AUTHOR π
Merten Falk, "<nevesenin at cpan.org>". and now it's maintained by Lee Johnson (LEEJO) with contributions from:
Alexander Krizhanovsky <ak@natsys-lab.com>
Bas Bloemsaat <bas@bloemsaat.com>
girst <girst@users.noreply.github.com>
Ankit Pati (ANKITPATI) <contact@ankitpati.in>
the whole squad. we love a collaborative effort π«Ά
π 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. so like, you file it, i see it, you get updates. the pipeline is real. π
π SUPPORT π
you can find documentation for this module with the perldoc command.
perldoc HTML::Packer
go on, run it, it's right there π
πΈ COPYRIGHT & LICENSE πΈ
Copyright 2009 - 2011 Merten Falk, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. free as in freedom, bestie ποΈ
β SEE ALSO β
HTML::Clean
and that's the whole page, no crumbs left. this was HTML::Packer(3pm) from perl v5.40.0, dated 2024-10-12, and it lives in the User Contributed Perl Documentation section. go forth and minify, you gorgeous little compressor. mwah πβ¨π
π¦ where this page comes from
- ubuntu resolute: libhtml-packer-perl 2.110000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-packer-perl 2.110000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms