Combine is a small PHP script and some clever URL rewriting designed to speed up the loading of pages that use many or large css and javascript files.
It is good but how can you integrate it with your CakePHP project? And solution comes with the question
.
Download a copy of combine.php and drop it into your “app/webroot” directory (or whatever your application folder name is XXX/webroot/).
Open the file in your text editor and change lines:
$cachedir = dirname(__FILE__) . '/cache'; $cssdir = dirname(__FILE__) . '/css'; $jsdir = dirname(__FILE__) . '/javascript';
with
$cachedir = dirname(__FILE__) . '/../tmp/cache'; $cssdir = dirname(__FILE__) . '/css'; $jsdir = dirname(__FILE__) . '/js';
Open your “app/webroot/.htaccess” file and add those two lines
RewriteRule ^css/(.*\.css) combine.php?type=css&files=$1 RewriteRule ^js/(.*\.js) combine.php?type=javascript&files=$1
That’s all! Check download times of your css and javascript files with a tool like Firebug. A fatty 527KB ext-all.js javascript framework file compressed to 140KB! Amazing ha?