Minifies the HTML document with the inputted or default options.
$doc = new \hexydec\html\htmldoc();
if ($doc->load($html)) {
$doc->minify($options);
}
An optional array contains a list of configuration parameters to configure the minifier output, the options are as follows and are recursively merged with the default config:
Parameter | Type | Options | Description | Default |
---|---|---|---|---|
lowercase |
Boolean | Lowercase tag and attribute names | true |
|
whitespace |
Boolean | Strip whitespace from text nodes (Preserves whitespace between inline items defined in htmldoc::$config['elements']['inline'] ) |
true |
|
comments |
Array | Options for removing comments | Array() |
|
comments |
Whether to remove comments | true |
||
ie |
Whether to preserve Internet Explorer specific comments | true |
||
urls |
Array | Minify internal URL's | Array() |
|
scheme |
Remove the scheme from URLs that have the same scheme as the current document | true |
||
host |
Remove the host for own domain | true |
||
relative |
Process absolute URLs to make them relative to the current document | true |
||
parent |
Process relative URLs to use parent folders (../ ) where it is shorter |
true |
||
attributes |
Array | Minify attributes | Array() |
|
trim |
Trim whitespace from around attribute values | true |
||
default |
Remove default attributes as defined in htmldoc::$config['attributes']['default'] |
true |
||
empty |
Remove attributes with empty values, the attributes processed are defined in htmldoc::$config['attributes']['empty'] |
true |
||
option |
Remove the value attribute from option tags where the text node has the same value |
true |
||
style |
Remove whitespace and last semi-colon from the style attribute |
true |
||
class |
Remove unnecessary whitespace from class attributes | true |
||
sort |
Sort attributes for better gzip compression | true |
||
boolean |
Minify boolean attributes to render only the attribute name and not the value. Boolean attributes are defined in htmldoc::$config['attributes']['boolean'] |
true |
||
singleton |
Boolean | Removes spaces and slash in singleton attributes, e.g. <br /> becomes <br> |
true |
|
quotes |
Boolean | Removes quotes from attribute values where possible | true |
|
close |
Boolean | Removes closing tags for elements defined in htmldoc::$config['elements']['closeoptional'] where possible |
true |
|
email |
Boolean | Sets the minification presets to email safe options | false |
void