CI Minify

Jesse van Assen edited this page Jun 23, 2013 · 12 revisions
Clone this wiki locally


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 to 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/colorbox.js';
echo $this->minify->js->min($file);

Minify CSS file

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

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

$this->minify->combine_files(array('test/css/calendar.css', 'test/css/colorbox.css');

Minify and save a physical file

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

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

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