Book Image

CakePHP 2 Application Cookbook

Book Image

CakePHP 2 Application Cookbook

Overview of this book

Table of Contents (20 chapters)
CakePHP 2 Application Cookbook
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

The AssetCompress plugin


The handling of static assets, such as scripts and stylesheets, is an important aspect of applications that are expected to perform and deliver content quickly.

In this recipe, we'll look at how to include and set up the AssetCompress plugin to make sure we're serving content quickly and efficiently, without putting a burden on the server when the users are coming.

Getting ready

The AssetCompress plugin can be found at https://github.com/markstory/asset_compress.

The content of this plugin needs to be added in app/Plugin/AssetCompress/ and then loaded in your application. To do so, add the following code in your bootstrap.php file located in app/Config/:

CakePlugin::load('AssetCompress', array('bootstrap' => true));

This should be added before the section of the file that calls the following:

Configure::write('Dispatcher.filters', array(
  'AssetDispatcher',
  'CacheDispatcher'
));

Now, create an app.js file in app/webroot/js/, and create an app.css file in app/webroot...