One line script to minify js css directory using yuicompressor

The default installation of WordPress use full version of css and javascript library. In order to minify all of these files, I wrote this bash script to minify all of them. There will be no progress bar while minifying, so be patient.

cd wordpress
find -H . -type f -writable  \( -name \*.css -o -name \*.js \)  \
-exec sh -c "yuicompressor {} -o /tmp/yui.tmp && mv /tmp/yui.tmp {}" \;

This will only work under POSIX system.
Findutils should be included in most popular Linux distros.
Yuicompressor can be downloaded from here.

  • http://blog.mudy.info/2009/02/how-to-use-simplecdn-with-wordpress/ How to use SimpleCDN with WordPress | Mudy’s Blog

    [...] address.Before you proceed, please read my previous posts on how to use CNAME with SimpleCDN and how to process javascript and css files for WordPress. Make sure your SimpleCDN’s CNAME and bucket working properly. I used a mirror bucket which [...]

  • http://joyunbound.com Joshua Szanto

    How safe is this? Could you give a “before and after” example of an original script to a minified version? Thanks!