JS and CSS compress

The following shell script can be use for compiler.jar and yuicompressor-x.y.z.jar
Using compiler.jar


files=`find  -name "*.js"`

echo "======= S T A R T J S C O M P R E S S ======="
for i in $files;
do
 echo "Starting compress for "$i

#Debug mode
 #java -jar compiler.jar $i --js_output_file new/$i.js

#Non debug mode
 #java -jar compiler.jar $i --compilation_level SIMPLE_OPTIMIZATIONS -- js_output_file compressed/$i --warning_level QUIET --summary_detail_level 3

echo "Compress finished for "$i
 echo "==========================="
done<
echo "======= J S C O M P R E S S D O N E ======="

Using yuicompressor-x.y.z.jar

For JS

files=`find  -name "*.js"`

echo "======= S T A R T J S C O M P R E S S ======="
for i in $files;
do
 echo "Starting compress for "$i

#Debug mode
 #java -jar yuicompressor-2.4.jar $i -o compressed/$i --charset utf-8 --verbose

#Non debug mode
 java -jar yuicompressor-2.4.jar $i -o compressed/$i --charset utf-8

echo "Compress finished for "$i
 echo "==========================="
done
echo "======= J S C O M P R E S S D O N E ======="

For CSS


files=`find  -name "*.css"`
echo "======= S T A R T C S S C O M P R E S S ======="
for i in $files;
do
echo "Starting compress for "$i
#Debug mode
#java -jar yuicompressor-2.4.jar $i -o compressed/$i --charset utf-8 --verbose

#Non debug mode
java -jar yuicompressor-2.4.jar $i -o compressed/$i --charset utf-8

echo "Compress finished for "$i
 echo "==========================="
done
echo "======= J S C O M P R E S S D O N E ======="

Save the code as [filename].sh and run as $sh ./[filename].sh , make sure [filename].sh has execution permission

Advertisements