home
##The home page for li3_assets

Provides tools for automatic asset handling, compression, concatenation and minification.

Example Usage:
In your libraries.php file:
{{{
Libraries::add('li3_assets', array(
  'config' => array(
       'js' => array(
            'compression' => 'packer', // possible values: 'jsmin', 'packer', false (true uses jsmin)
            'output_directory' => 'optimized', // directory is from webroot/css if full path is not defined
            'packer_encoding' => 'Normal', // level of encoding (only used for packer), possible values: 0,10,62,95 or 'None', 'Numeric', 'Normal', 'High ASCII'                                                      
            'packer_fast_decode' => true, // default: true
            'packer_special_chars' => false // default: false
       ),
       'css' => array(
            'compression' => 'tidy', // possible values: true, 'tidy', false
            'tidy_template' => 'highest_compression',
            'less_debug' => false, // debugs lessphp writing messages to a log file, possible values: true, false
            'output_directory' => 'optimized' // directory is from webroot/css if full path is not defined
       ),
       'image' => array(
            'compression' => true, // uses base64/data uri, possible values: true, false
            'allowed_formats' => array('jpeg', 'jpg', 'jpe', 'png', 'gif') // which images to base64 encode
       )
  )
));
}}}

Then in your layout template in your <head> section somewhere:
{{{
<?php
	echo $this->optimize->scripts();
	echo $this->optimize->styles();
?>
}}}

That should then combine and minify/pack your JavaScript and combine and tidy your CSS (depending on the settings you supplied to Libraries:add()). Also note that if you want to use less for your CSS, you can include your less files with the Html script helper, Html::script('sheet.less', array('inline' => false)); and it will be sent along to the scripts for layout as "sheet.less.css" but the Optimize::scripts() helper method will see that it is a less file and compile it to "sheet.less.css" so it will work out automatically. Then of course be combined with the rest of the CSS.


To get images to render as base64 data URIs you will need to at the top of each view template desired to render image data URIs add:
{{{
<?php $this->optimize->images(); ?>
}}}

Then a filter on Html::image() is applied so that all images (within the allowed type list) will be embedded on the page as data URIs. Keep in mind this is not supported by IE6 or IE7.

After that, you'll see at the top of your page in the <head> section links to CSS and/or JS files that contain a file name that's hashed. This is to keep track of which scripts go with which page. That file is written to disk. If you make updates, you will need to manually remove this file name so things can update and recompile.