Yuicompress

From Attie's Wiki
Jump to: navigation, search

Use the following code with Yahoo's YUIcompressor

#!/bin/bash
if [ "$#" == "0" ]; then
  echo "Usage: $0 file1 [file2 ...]"
  exit 1
fi
while (( "$#" )); do
  TYPE=`echo $1 | awk -F . '{print $NF}'`
  echo -n "($TYPE) $1..."
  cat "$1" | java -jar yuicompressor-2.4.2.jar --type $TYPE > "$1.min"
  if [ "$?" == "1" ]; then
    echo "YUI Error"
    exit 1
  fi
  echo -n " >> `echo $1.min | awk -F / '{print $NF}'`"
  gzip -c "$1.min" > "$1.gz"
  if [ "$?" == "1" ]; then
    echo "GZip Error"
    exit 1
  fi
  rm "$1.min"
  echo " >> `echo $1.gz | awk -F / '{print $NF}'`"
  shift
done
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox