Asset Compress is CakePHP plugin for helping reduce the number of requests, and optimizing the remaining reqests your application makes for Javascript and CSS files.
- Development mode builder that rebuilds assets on each request.
- Command line build tool to compile static assets for deployment.
- Built-in support for LESScss, Sass and CoffeeScript, as well as several minifiers.
- Powerful and flexible filter system allowing you to add your own minifiers/pre-processors.
- Simple configuration file.
- Incremental builds that don't recompile assets when they don't need to be.
Clone or download the plugin into one of your plugin paths. Then make sure you load the plugin:
// in app/Config/bootstrap.php
CakePlugin::load('AssetCompress');
From there read the wiki for more information.
Documentation for AssetCompress is available on the github wiki pages
Please report any issues you have with the plugin to the issue tracker on github.
Asset Compress is offered under an MIT license.
2010-2011 Mark Story (http://mark-story.com)
- Mark Story
- Ben McClure
- Igor Fomin (evilbloodydemon)
- Rachman Chavik
- Sumit Madan
- Florian Krämer
- Frank de Graaf (Phally)
- Alan Bount
- Abbas Ali
- Jeremy Harris
- rynop
- Cauan Cabral
- Renan Gonçalves
- Dave Baker
Backwards Incompatibile Changes:
baseUrl
now only takes effect when debug = 0. Build file existence is not checked anymore. It is assumed that build files exist at the location specified inbaseUrl
. Because of thisbaseUrl
will need to include the directory names as well.- Removed
General.writeCache
. It made for more complex deployments. InsteadGeneral.alwaysEnableController
has been added to allow the controller to be used in production instead of pre-generated static files. The default value is off.
Other changes:
- Support for CakePHP 2.0.
- Added
TimestampImage
filter class. This filter provides the ability to timestamp background images used in CSS files. This is useful for cache busting CSS sprites or other CSS background images. - Added
ROOT/
path variable for use in configuration files. - Added
ScssFilter
- Added support for plugin asset Using the
p:PluginName:resource.xx
syntax.
Backwards Incompatible Changes
- Ini file flag General.debug was removed. Instead Configure::read('debug') is used. This means one less configuration option to manage. Use debug = 1 to test output filters.
- The timestamp file format has changed. Remember to clear all builds when upgrading.
- A number of internal API changes have been made. If you are using the internals of AssetCompress you may have to update your code.
- The
General.timestampFile
config option was removed. Timestamp files are always used now.
Other changes
- Ini file naming for build files made simpler. Instead of having to
prefix sections with the extension you can omit the prefix. The
extension will be read off of the build file name. Instead of
js_library.js
you can just uselibrary.js
as the build name. - Controller/view javascript files are now combined into minified asset automatically now.
- When using the shell, asset targets that are still fresh will be
skipped on subsequent builds. A target is fresh if the build file's
mtime is later than all of the files that go into the target. This
behavior can be ignored using the
-force
option. - If you don't define the
paths[]
keys in your js and css extensions, AssetCompress will recursively include all paths in the standard CakePHP directories. - Theme support has been added. When defining a build you can set
theme = true
in the build definition. When the shell is run, a build will be created for every theme installed. Themes support only works for builds defined in the ini file. - The timestamp file format has changed and contains timestamps for each build. This was required as part of the incremental builds feature.
Backwards Incompatible Changes
- Internals of the plugin re-factored and re-architected to be simpler.
- New configuration file format.
- Helper method changes, creating builds on the fly now works differently.
- Comment stripping features removed, you should use one of the built-in minifier integrations to accomplish this.
- Sprockets features and InlineImport feature extracted into filters.
- Helper methods changed.
Other changes
- CoffeeScript, and LESS css support added.
- Can add any additional attributes to generated link or stylesheet tags.
Backwards incompatible changes
- Inflection of file names for javascript and css was removed. This affects both the helper, and the directives supported by each file type.
- Auto inclusion of all build files in the
afterRender()
callback was removed. You now need to manually callincludeAssets()
. - The default build file is now a magic-hash. Magic-hash build files, use the
md5()
of their components as the build filename. This allows you to easily create build files without worrying about keeping them unique across your application.
Other changes
AssetCompressHelper::includeAssets()
takes an array of build files you wish to output in that call. This lets you place some build files at the top of the document, and others at the bottom.AssetCompressHelper::includeJs()
andAssetCompressHelper::includeCss()
were added. These methods function similar toincludeAssets()
. Each allows you to only include some of the build files.- Assets that do not exist now return 404 errors.
- Two basic filters have been added.
JsMin
andCssMin
are now built-in filters. Both require you to put their libraries inapp/vendors
. - Filters for YUI Compressor have been added. Both a CSS and Javascript filter have been added. They require you to put yuicompressor in your app's vendors directories.
- The asset_compress shell can now generate build files. This allows you to integrate asset generation into your deployment/build scripts.
- Timestampping of build files was added.
- Filters for CSS files were fixed.
- Location for asset_compress.ini file was moved into
app/config/asset_compres.ini
. - Files in themes should now be auto discovered.