Asset Bundler

The asset bundler is a plugin to easily add bunding and compression for your javascript and stylesheet files. This allows you to keep a neat and organized javascript or css library and combine and minify the files in your testing and production environments.

This plugin will override existing functionality within the Wheels core API and add a new method.

New Methods

Use the generateBundle() method in /events/onapplicationstart.cfm to specify the bundles that you want to create when in testing or production mode. The method should only be used here to ensure that your bundles are created before the application starts serving requests.

The source/sources argument you specify for this method will be saved by the asset bundler. In your layout file, you will only need to call javaScriptIncludeTag() or styleSheetLinkTag() with the proper bundle name and the asset bundler will decide what link or script tags to produce based on your environment settings. An example is below.

... in /events/onApplicationStart.cfm
<cfset generateBundle(type="css", bundle="bundles/core", compress=true, sources="screen,liquid,style") />
... in your layout file - maybe /views/layout.cfm

When in the design, development and maintenance the code about will output <link /> tags for each source listed. In the testing and production evnironments the same code will produce one <link /> tag pointing to /sytlesheets/bundles/core.css (per the example above).

Overridden Methods

How to Use

Once installed, simply use the functions listed above with the proper parameters. When calling these methods, please make sure to specify argument names to keep conflicts from occurring when not using the plugin. For example, do styleSheetLinkTag(sources="core,layout,theme", bundle="all").

When in the Testing or Production environments, the plugin will bundle your assets as specified. The bundling will occur onApplicationStart() or when you add the reload parameter into the URL and reload the application.

If you would like to create multiple bundles, simply call the generateBundle() method multiple times using different bundle names. Please make sure to not repeat bundle names as this will have unintended consequences.

Once a bundle is created it will not be recreated until the parameter "reload" is detected in the url. This gives you complete control over when the bundle is rebuilt. This is also done to limit file system access while serving bundles in a production environment.

Shared Hosting Environments

I am also pleased to note that this plugin has no dependency on the internal Coldfusion objects so it can be used in shared hosting enviroments where the setting "Disable access to internal ColdFusion Java components" is turned on.


A big shout out goes to Mark Mandel who is the creator of JavaLoader which is used in this project. Also, a big thank you to the YUI for creating the awesome YUI compressor. And last but not least, a big thanks to the wheels core team for creating such an awesome framework.

Road Map

I would like to add the following features to the plugin to make it to a 1.0 release.


To uninstall this plugin simply delete the /plugins/ file.


This plugin was created by James Gibson.

<<< Go Back