Asset Compress plugin released

I’ve just released another plugin for CakePHP. This one helps reduce the number of HTTP requests made by helping you concatenate and compress your asset files. I’ve been working on it on and off for about 3 months now, and am pretty happy with where it is. It includes both server side and client side libraries for loading compressed files. This site is using the plugin as well for the CSS and Javascript files. So if you are looking for a working example, you’ve come to the right place. I’ve written a bunch of documentation for the plugin on github. It requires at least CakePHP 1.3RC1 and PHP5.2+. I hope you find it as useful as I do, and if you have any issues with drop me a line or open a ticket on github.

Comments

Ever since i saw your tweet teasing this i have been waiting patiently for its release, I will be implementing this in a few of my projects right away!

Mark Beukers on 3/21/10

Great plugin, I hope to migrate some of my apps to 1.3 shortly and this will definitely come in handy.

Thanks

Andrew on 3/22/10

I’ve been looking for something like this – thank you… Will be installing this soon.

Daniel on 3/22/10

I am very interested in this plugin – it seems so fully featured. With some exceptional ideas.

I am trying it for the second time now but I am just not able to get it to process css (not yet moved on to js)

i notice that your paths to compressed css differ from mine

/cache_css/stylesheet.css?file[]=screen

how come what gives? any clues? I am on windows – will try on a real server later

Majic on 4/2/10

Thnak you for this great 1.3 ready plugin!

Just a little note:
you forgot to include ‘filters’ in CssFile::_configProperties array.
I added it and now CssMin filter runs smoothlessly! ;-)

d3v3d3 on 4/4/10

d3v3d3: Good catch, I’ve added that into the _configProperties in the repository.

Majic: Perhaps you are missing some routes?

mark story on 4/4/10

Great plugins.

I have a problem with this plugins :(. I did all that appear in wiki but my default.css and default.js are empty

any idea?

S.

stefano on 4/7/10

@Mark: I have routes set no joy; on windoze nor nix; I am using cake1.3

on nix the plugin outputs /lab/ac/lab/ac/cache_css/default.css?file[]=cake.generic

I have baked an app into /lab/ac – if I remove the first /lab/ac I see the output and comments are stripped.

I have tried altering the plugin config settings – but not made it work

any suggestions

majic on 4/7/10

Majic: Seems like there was a problem when apps were in subdirectories. It should be fixed by this commit

mark story on 4/7/10

I have pulled the latest (I only have it subdir for testing)

More is certainly working now. What does not seem to work is changing the config’d asset cache dir in asset_compress/config/config.ini – I change the to ccss & cjs (though so far I am only testing cake.generic.css)

also though I have cache files set to true the asset cache dir are empty (are writeable – I have changed back to the default cache_css)

and also I don’t get the clean asset paths that I see when viewing your source (on this here site)

I will recheck that I have followed the wiki, maybe I have missed something obvious.

Majic3 on 4/8/10

I have resolved some of my issues with the plugin.

The cached assets are not made unless I use the asset_compress/css_file/get/KEY (same applies to js)

I had missed the second param in the AC helper

I can’t have either js/css in subdirs – it makes no difference if the subdir is listed in ini config

the major issue was setting up the filters to work correctly – since no debug output and it took some time to workout have to trackdown possible leads

do you have any idea what to do about the searching subdirs?

Majic3 on 5/3/10

Majic3: I haven’t run into any issues with searching sub directories, as long as the sub directories were in the ini file. It is true that the cached assets will only get created if you hit the route pointing at the plugin, in the wiki I think I mention that making your route and cacheFilePath should be the same for the caching to actually ‘work’.

mark story on 5/3/10

Sorry but i think im doing something really dumb and i can’t work out what.

Ive added the plugin and the routes & ini. my app is 1.3 and very standard.

in app controller ive added the helper, ‘AssetCompress.AssetCompress’

and in my default layout, i changed how i add css like this:

//echo $html->css(array(‘reset’, ‘text’,‘site’));
echo $assetCompress->css(array(‘reset’,‘text’,‘site’));

But the css goes away. :(

looking at the helper, debug($this->_css); shows the list corectly when function css is called, but by the time the afterRender function is called, the list is blank.

What might i be missing? am i going about using the helper all wrong?

Thanks for any help.
Will

will on 8/10/10

I got this working in the end. The docs over at git hub helped! thank you very much for this fine and very useful piece of work.

Will

will on 10/26/10

Great plugin!

As for Cake 2.0, perhaps you should update the docs. It definitely needs

CakePlugin::load(‘AssetCompress’);

in bootstrap.php, took me a while to figure this out. I first though when including the helper the plugin is loaded automatically

wirtsi

Wirtsi on 12/2/11

Wirtsi: I updated the README and the wiki docs, thanks for pointing that out :)

mark story on 12/3/11

This plugin is awesome, @Mark, but I’m having some problems with it.
I’m trying to use the the CKEditor script (http://ckeditor.com), which already has a “minified” JS script version, and is stopping working when I use the AssetCompress plugin on my website. I’m having the same problem with other scripts, that when they are “minified”, some functions such as incrementing a variable, stop working too.

Do you have any idea how I can solve this problem or the problem is the plugin?

Gabriel Lau on 3/23/12

Comments are not open at this time.