Merge JS and CSS file to make your codeigniter website faster using CARABINER library
Carabiner is a library for managing JavaScript and CSS assets. It's different from others that currently exist (for CodeIgniter, anyway) in that it acts differently depending on whether it is in a production or development environment. In a production environment, it will combine, minify, and cache assets. (As files are changed, new cache files will be generated.) In a development environment, it will simply include references to the original assets.
$this->load->library('carabiner');
$carabiner_config = array(
'script_dir' => 'assets/scripts/',
'style_dir' => 'assets/styles/',
'cache_dir' => 'assets/cache/',
'base_uri' => $base,
'combine' => TRUE,
'dev' => FALSE
);
$this->carabiner->config($carabiner_config);
// Define JS
$js = array(
array('prototype.js'),
array('scriptaculous.js')
);
// create group
$this->carabiner->group('prototaculous', array('js'=>$js) );
// an IE only group
$css = array('iefix.css');
$js = array('iefix.js');
$this->carabiner->group('iefix', array('js'=>$js, 'css'=>$css) );
// you can even assign an asset to a group individually
// by passing the group name to the last parameter of the css/js functions
$this->carabiner->css('spec.css', 'screen', 'spec-min.css', TRUE, FALSE, 'spec');
for downloading the library and more detail use the below link
https://github.com/bcit-ci/CodeIgniter/wiki/Carabiner
$this->load->library('carabiner');
$carabiner_config = array(
'script_dir' => 'assets/scripts/',
'style_dir' => 'assets/styles/',
'cache_dir' => 'assets/cache/',
'base_uri' => $base,
'combine' => TRUE,
'dev' => FALSE
);
$this->carabiner->config($carabiner_config);
// Define JS
$js = array(
array('prototype.js'),
array('scriptaculous.js')
);
// create group
$this->carabiner->group('prototaculous', array('js'=>$js) );
// an IE only group
$css = array('iefix.css');
$js = array('iefix.js');
$this->carabiner->group('iefix', array('js'=>$js, 'css'=>$css) );
// you can even assign an asset to a group individually
// by passing the group name to the last parameter of the css/js functions
$this->carabiner->css('spec.css', 'screen', 'spec-min.css', TRUE, FALSE, 'spec');
for downloading the library and more detail use the below link
https://github.com/bcit-ci/CodeIgniter/wiki/Carabiner
Comments
Post a Comment