I have been using YUI Compressor (called via PHP script) to minify a combined file. At fist, I combined the file then minified it, but now I am minifying the files and then combining them. This potentially saves time, if not all (~40+ scripts and css files) have changed.
What I notice is, that the total process of minifying 40 files takes significantly longer (approx 120+ seconds) whereas the combined file took significantly less time to minify.
You can leave the philosophy of combining first vs after, but does anyone know the reason for this issue? Possibly could it be due to the initialization time of the application?
I am using this code:
$yui_jar = $this->fitango_root.'/js/yuicompressor-2.4.7.jar';
$command = "java -jar $yui_jar $filename -o $path_file";
echo "MINIFYING: $filename\n";
exec ($command,$result);
It will be the Java JVM startup time. Although not documented on the YUI compressor page, it does support wildcard conversion into single files:
java -jar yuicompressor-2.4.8.jar -o ".js$:-min.js" *.js
I've just tested that locally and can confirm it's working. If you run the compressor with no arguments, you get a more up-to-date list of options, which is where I got the above from