PHP code example of arjanschouten / htmlminifier

1. Go to this page and download the library: Download arjanschouten/htmlminifier 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/ */

    

arjanschouten / htmlminifier example snippets


composer 

composer 

//include the composer autoloader
 will be used through the minification process
$context = new MinifyContext(new PlaceholderContainer());
// save the html contents in the context
$context->setContents('<html>My html...</html>');
$minify = new Minify();
// start the process and give the context with it as parameter
$context = $minify->run($context);

// $context now contains the minified version
$minifiedContents = $context->getContents();


...
$options = [
  'whitespace' => false,
  'remove-defaults' => true,
];

$minify->run($context, $options);
unit