Mecha CMS

Mecha CMS blog and documentation.

How to Automatically Minify CSS and JavaScript Files

Updated: Sunday, 07 August 2016

Asset detracting.

To automatically combine and minify your CSS and JavaScript files, find lines of code that look like these, usually can be found in header.php and footer.php:

<?php echo Asset::stylesheet(array(
    'assets/shell/atom.css',
    'assets/shell/layout.css'
)); ?>
<?php echo Asset::javascript('assets/sword/layout.js'); ?>

Edit the code above like this:

<?php echo Asset::stylesheet(array(
    'assets/shell/atom.css',
    'assets/shell/layout.css'
), "", 'name-of-the-asset.min.css'); ?>
<?php echo Asset::javascript('assets/sword/layout.js', "", 'name-of-the-asset.min.js'); ?>

Done. More information about this feature are available in the Asset class reference.

Donation and Email Subscription