HTML::Packer(3pm)

πŸ“¦
version 2.110000 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 if remove_comments has a true value. BUT. not me protecting the special ones πŸ™ˆ β€” comments starting with "<!--#", "<!--[" or "<!-- google_ad_section_" will be preserved unless remove_comments_aggressive has a true value. so those little guys are safe… for now.
  • remove_comments_aggressive β€” see remove_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 if remove_newlines has 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 if JavaScript::Packer is 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 if CSS::Packer is 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 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