브라우저에 캐쉬되는 파일의 압축을 통해서 성능을 향상시키는 방법.

개발중에는 필요없지만, 배포를 위해서라면 성능을 향상시킬 필요가 있을경우
야후에서 BSD라이센스로 제공하는 compress 를 사용할 수 있다.

홈페이지 링크 : http://developer.yahoo.com/yui/compressor/

다운로드 : http://yuilibrary.com/downloads/#yuicompressor


사용을 위해서 사용자 환경에 java가 설치되어있어야 한다.
java 설치가 되어있는 환경이라면 아래와 같이 사용가능하다.

java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js

Global Options
-h, --help Displays this information
--type <js|css> Specifies the type of the input file
--charset <charset> Read the input file using <charset>
--line-break <column> Insert a line break after the specified column number
-v, --verbose Display informational messages and warnings
-o <file> Place the output into <file>. Defaults to stdout.

JavaScript Options
--nomunge Minify only, do not obfuscate
--preserve-semi Preserve all semicolons
--disable-optimizations Disable all micro optimizations


css파일과 js파일이 많은 경우에 한번씩 실행시키기 위해서..
editplus에 약간의 수정을 가했다.

다운받은 yuicompressor-2.4.2.jar 파일을 임의의 곳에 옮긴 후
(나의 경우는 아래보는것처럼 C:\xampp\yuicompressor-2.4.2.jar에 있다)
editplus 메뉴 중 도구 > 사용자도구 구성을 추가해서 아래와 같이 설정해준다.

메뉴제목
YUI COMPRESSOR

명령
C:\Program Files\Java\jre6\bin\java.exe

인수
-jar C:\xampp\yuicompressor-2.4.2.jar --charset utf-8 --line-break 100 -v --preserve-semi $(FilePath) -o $(FileDir)/$(FileNameNoExt)-min.$(FileExt)

출력내용캡쳐에 체크.

인수의 내용은 파일을 연 디렉토리에 파일명-min 이라는 이름으로 압축된 파일을 생성하라는 뜻이다.

+ Recent posts