Ask questions and get good answers on jQuery

vote up 0 vote down
star

I need to minify my jquery plugin code to reduce filesize; Can anyone suggest a good tool?

flag

3 Answers

vote up 2 vote down

Also worth a mention is Dojo Shrinksafe.

To compare the decode times and compression ratios of the various compressors out there, you might want to take a look at CompressorRater

link|flag
vote up 0 vote down
check

Generally the best way to do it is to use the YUI compressor.

An alternative is to use Douglas Crockford's JSMin. This doesn't compress JavaScript code as small, but generally how you write your code matters less. jQuery also provides a pre-minified version of jQuery for your convenience.

Packing javascript using Dean Edwards' Packer (specifically using the base64 encode) is not recommended, as the client-side decoding has significant overhead that outweighs the file-size benefits.

If compressing your JavaScript breaks it, try running the code through JSLint. This will detect minor errors that can cause packed JavaScript to fail where the unpacked version works fine.

link|flag
vote up 0 vote down

Apparently Packer does a pretty good job even if you turn off the base62 encoding. Worth considering.

Also this is worth checking out : http://closure-compiler.appspot.com/home

link|flag

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.