PHP code example of codealfa / minify

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

    

codealfa / minify example snippets


use CodeAlfa\Minify\Js;

$sMinifiedJs = Js::optimize($sOriginalJs);

use CodeAlfa\Minify\Html;

$aOptions = array(
    'cssMinifier' => array('CodeAlfa\Minify\Css', 'optimize'),
    'jsMinifier'  => array('CodeAlfa\Minify\Js', 'optimize'),
    'minifyLevel' => 2,
    'isHtml5'     => true
);

$sMinifiedHtml = Html::optimize($sOriginalHtml, $aOptions);