Skip to content
Minify css and js files in CodeIgniter
PHP JavaScript CSS
Find file
New pull request
Latest commit e7b432c @ericbarnes Update

CodeIgniter Minify

Please note this project is no longer maintained.

The goal of this project is to provide a simple way to minify and combine js and css files inside a CodeIgniter application. Currently other systems exists but I wanted the compression to be part of my build process. So on deployments I compress and minify all the js and css. Then push off to s3 but this could also be useful to write them to a single file.


Upload the Minify folder to your libraries folder. This is built using CI2 packages and you must be using CI2.


Below is an overview of different usages:

Minify JS file

$file = 'test/js/test1.js';
echo $this->minify->js->min($file);

Minify CSS file

$file = 'test/css/test1.css';
echo $this->minify->css->min($file);

Minify String

$content = 'body{ padding:0; margin: 0}';
echo $this->minify->css->min($content);

Minify and combine an array of files. Useful if you need files to be in a certain order.

$files = array('test/css/test2.css', 'test/css/test1.css');
echo $this->minify->combine_files($files, [optionalParams]);

Minify and save a physical file

$file = 'test/css/test1.css';
$contents = $this->minify->css->min($file);
$this->minify->save_file($contents, 'test/css/all.css');

Minify an entire directory. The second param is an array of ignored files.

echo $this->minify->combine_directory('test/css/, array('all.css'), [optionalParams]);

Optional Params

combine_files($files, [type], [compact], [css_charset]);
combine_directory($directory, [ignore], [type], [compact], [css_charset]);


[compact] : bool (TRUE, FALSE). TRUE Compact/compress output, FALSE doesn't compress output (only aggregation)
[css_charset] : string (default 'utf-8'). If CSS you can force a starting single charset declaration (when aggregate files)
               due to the charset pre-removal (for stantdars compliance and Webkit bugfix prevention)
               set to null or leave empty if JS.

Combine dir:

[ignore] : array with files to ignore


fsencinas - ( JS-Min - (

Something went wrong with that request. Please try again.