CodeIgniter Forums

Full Version: Minifier - asset minification and versioning library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
https://github.com/michalsn/minifier

Installation:

Code:
composer require michalsn/minifier


Configuration:

PHP Code:
public $js = [
    
'all.min.js' => [
        
'jquery-3.2.1.min.js''bootstrap-3.3.7.min.js''main.js',
    ]
]; 
Code:
php spark minify:js


Usage:

PHP Code:
<?= minifier('all.min.js'); ?>
// will produce
// <script type="text/javascript" src="http://localhost/assets/js/all.min.js?v=9ef881911da8d7c4a1c2f19c4878d122"></script> 
It looks useful. Thanks!

In what file do I need to write "public $js = [...]"?
It's in the "Config/Minifier.php" file. You can run command:
Code:
php spark minify:publish

to copy the default config file to your application and then modify it to your needs.
hello

i tried this library

and used the installation via composer

but the function Minifier() is not found

"Call to undefined function Minifier()"

do you know how to fix it

thx
Hi Paul,

You probably need to load a helper in your controller

Code:
helper('minifier');
yes that works

thanks
this package is good but maybe the Dir config will be upgrade

for me the URL to css is css.mydomaine.com/mycss.css and the dir to css file in php is ../system/assets/css/mycss.css

i think the four parameters $baseUrl, $dirJs, $dirCss, $dirVersion would be changed by $UrlJS, $UrlCss, $dirJs, $dirCss, $dirVersion

what do you think of that
Well, yes... separate URL config like $cssUrl and $jsUrl might be a good addition if someone would like to serve these files from a separate domain.

Thanks for the idea.
yes and i think it's useful if the public directory is not at the same level of the assets directory
I tried used this package in manual installation mode and all the command php spark minify:* are not found

do you know how to fix it
Pages: 1 2