Just a quick note for all of those looking to optimize their JS/CSS in CakePHP. The awesome Matt Curry put together a CakePHP plugin which makes this incredibly easy. Here is his Asset plugin on Github.
It works almost perfectly right out of the box but I ran into a small problem when setting it up on one of my sites. The Javascript component of TinyMCE does not play well with JSMin and is rendered useless when you run it through Asset.
Unfortunately, I load the TinyMCE scripts within my view but they need to appear within the <head> tag. Because Asset filters all scripts that are passed through the Javascript Helper with the inline => false parameter, there was no avoiding it. I ended up hacking away at the plugin a bit to add a Configure option which lets you specify files to output directly (and not compress/combine with the rest). Check out my fork of mcurry’s asset on Github.
It’s a small hack that should rarely need to be used, and be aware that using it will likely mess up the order of your JS. If the order in which your scripts are output is important, than it might not work for you. Usage is quite simple and is explained in the README.
Questions and comments are welcome!
