ProCache Minify HTML
Contains methods to implement ProCache’s HTML minification features.
Note that documentation in this section uses $min
to refer to $procache->minifyHTML
, like in the example below.
$html = "<html><body>HTML document markup here</body></html>";
$min = $procache->minifyHTML; // get instance to start using HTML minify
echo "<h1>Original</h1>" . htmlspecialchars($html);
$html = $min->minify($html);
echo "<h1>Minified</h1>" . htmlspecialchars($html);
Default “blocks”
These are block level elements that will have whitespace collapsed around them.
!doctype, address, article, aside, audio, blockquote, body, br, button, canvas, caption, col, colgroup, dd, div, dl, dt, embed, fieldset, figcaption, figure, footer, form, head, header, hgroup, hr, html, li, link, main, map, meta, nav, noscript, object, ol, optgroup, option, output, p, pre, progress, script, section, table, tbody, td, tfoot, th, thead, title, tr, ul, video, h1, h2, h3, h4, h5, h6
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon.
Common
Properties
Name | Return | Summary | |
---|---|---|---|
$min->blankAttrs | string array | Attributes that may be removed when blank DEFAULT: ['class', 'dir', 'for', 'id', 'lang', 'style', 'title'] | |
$min->blocks | string array | Tags that we will collapse whitespace around DEFAULT: see above | |
$min->collapseBooleanAttr | bool | Collapse boolean attributes, where allowed by HTML5? DEFAULT: true | |
$min->convertXHTML | bool | Convert XHTML style "/>" closing tags to HTML ">"? DEFAULT: true | |
$min->cssMinifyFunction | callable | Optional callback function to use for CSS minification, see setCSSMinifyFunction() method DEFAULT: null | |
$min->ignoreTags | string array | Tags that should be ignored during minification DEFAULT: ['script', 'style', 'pre', 'textarea', 'svg'] | |
$min->jsMinifyFunction | callable | Optional callback function to use for JS minification, see setJSMinifyFunction() method DEFAULT: null | |
$min->removeBlankAttr | bool | Remove blank attributes, where allowed? (configurable, default=true) | |
$min->removeComments | bool | Remove HTML comments? DEFAULT: true | |
$min->removeUnnecessaryAttr | bool | Remove unnecessary/redundant attributes from HTML tags? DEFAULT: true | |
$min->removeUnnecessaryTags | bool | Remove unnecessary/redundant HTML tags? DEFAULT: true | |
$min->unquoteAttr | bool | Remove quotes from attributes, where allowed by HTML5? DEFAULT: true |
API reference based on ProcessWire core version 3.0.252