Skip to content
Jesse van Assen edited this page Jun 23, 2013 · 12 revisions

Overview

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.

Installation

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

Usage

Below is an overview of different usages:

Minify JS file

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

Minify CSS file

$this->load->driver('minify');
$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->load->driver('minify');
$this->minify->combine_files(array('test/css/calendar.css', 'test/css/colorbox.css');

Minify and save a physical file

$this->load->driver('minify');
$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->load->driver('minify');
$this->minify->combine_directory('test/css/, array('all.css'));
Clone this wiki locally