PHP code example of myjw3b / minify

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

    

myjw3b / minify example snippets


/* example
*
*	@type = css || js
*	@files = array of the files to compress
*	@file = the /path/to/savedFile.css of the file
*
*	function compress($type, $files, $file)
*
*	// the numbers is the filemtime() of the cache file
*	@return '/path/to/savedFile.css?vers=987589745';
*/
use JW3B\core;

// to compress css files
$CSSFiles = [
	'/style/css/fonts/Lilly-fontfacekit/stylesheet.css',
	'/style/css/bootstrap.css',
	'/style/css/bs_extended.css'
];
$min = new Minify;
$CSSFile = $min->compress('css', $CSSFiles, '/assets/compressedFiles/css.global.min.css');

// to compress javascript files
$JSFiles = [
	'/style/js/bootstrap.min.js',
	'/style/js/jquery.form.js',
	'/style/js/global.js'
];

$JSFile = $min->compress('js', $JSFiles, '/assets/compressedFiles/js.global.min.js');

// and then eco it out
echo '<link type="text/css" rel="stylesheet" href="'.$CSSFile.'">'.
	'<script type="text/javascript" src="'.$JSFile.'"></script>';