Since writing on this blog I posted two jQuery plugins and I needed to compress my js files. So as jQuery documentation suggests I used YUICompressor. YUICompressor is javascript and CSS file/code compressor written in Java language. So to run one yourself you will need JRE installed on your machine.
Then call this command:
java -jar /path/to/yuicompressor.jar path/to/file.js -o path/to/minimized.file.js
Your file will be compressed and saved to path you specified as the last parameter (in our case minimized.file.js).
Links:
- Download YUICompressor
- Download JRE (required to run java applications)
- Online version of YUICompressor
i use dean edwards packer to compress my javascript files - http://dean.edwards.name/packer/
ReplyDeleteFor those without JRE, I've created a small .net console application that uses the .NET YUI compressor libraries. See http://bit.ly/2ITdV
ReplyDeleteThe .NET library can also be used for MSBUILD steps..
Cheers, Erik
Heh, thanks for the post, turns out they have an Online compressor too: http://refresh-sf.com/yui/.
ReplyDeleteTakes 2 seconds, and they have decent options aswell. I got 16% cut, pretty sweet.
Exactly what I was looking for! I have a custom jquery script that is 146kb, I shrunk it down to 60kb.
ReplyDeleteThank you
can we compress JQuery template with the help of YUICompressor
ReplyDelete