NOTE: Carabiner has been updated to version 1.42. See the new thread for more info and to download.
Carabiner requires the JSMin and CSSMin libraries that I previously ported. They’re both included in this release. You don’t need to load them, unless you’ll be using them elsewhere. Carabiner will load them automatically as needed. (Note: the only reason they’re included as separate libraries is that it allows you to use them independently of Carabiner. If desired, you could probably include them in the carabiner.php file itself. You’d have to edit the Carabiner functions, but it could work.)
GZIP, Packer, etc.
Load the library as normal:
Configure it like so:
$carabiner_config = array(
'script_dir' => 'assets/scripts/',
'style_dir' => 'assets/styles/',
'cache_dir' => 'assets/cache/',
'base_uri' => $base,
'combine' => TRUE,
'dev' => FALSE
There are 8 relevant configuration options. The first 4 are required for Carabiner to function, the last 4 are not.
STRING Path to the script directory. Relative to the CI front controller (index.php)
STRING Path to the style directory. Relative to the CI front controller (index.php)
STRING Path to the cache directory. Must be writable. Relative to the CI front controller (index.php)
STRING Base uri of the site, like ‘http://www.example.com/’
BOOLEAN Flags whether your in a development environment or not. See above for what this means. Defaults to FALSE.
BOOLEAN Flags whether to combine files. Defaults to TRUE.
BOOLEAN Flags whether to minify CSS. Defaults to TRUE.
Add assets like so:
To set a (prebuilt) production version of an asset:
// pass a second string to the method with a path to the production version
$this->carabiner->css('wymeditor/wymeditor.js', 'wymeditor/wymeditor.pack.js' );
And to prevent a file from being combined:
// pass a boolean FALSE as the third attribute of the method
$this->carabiner->css('wymeditor/wymeditor.js', 'wymeditor/wymeditor.pack.js', FALSE );
You can also pass arrays (and arrays of arrays) to these methods. Like so:
// a single array
$this->carabiner->css( array('base.css', 'base.prod.css') );
// an array of arrays
$js_assets = array(
$this->carabiner->js( $js_assets );
To output your assets, including appropriate markup:
// display css
Finally, since Carabiner won’t delete old cached files, you’ll need to clear them out manually. To do so programatically:
// clear css cache
//clear js cache
// clear both
Please let me know what you think! If there’s something you would like changed or ad