PHP code example of wa72 / html-pretty-min

1. Go to this page and download the library: Download wa72/html-pretty-min library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wa72 / html-pretty-min example snippets



use Wa72\HtmlPrettymin\PrettyMin;

$pm = new PrettyMin();

$output = $pm
    ->load($html)   // $html may be a \DOMDocument, a string containing an HTML code, 
                    // or an \SplFileInfo pointing to an HTML document
    ->minify()
    ->saveHtml();

$dom_document = new \DOMDocument('1.0', 'UTF-8');
$dom_document->loadHTML('<html>...some html code...</html>');

$pm->load($dom_document)->minify();

echo $dom_document->saveHTML(); // Will output the minified, not the original, document