Compress jQuery


You may have written a jQuery plugin, and want to make a minimum version.

Generally the best way to do it is to use the YUI compressor. YUI stands for Yahoo! User Interface, YUI compressor is released by Yahoo! for free. So anyone can use it for commercial or non-commercial usage.

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. Douglas Crockford is the web architect at Yahoo! Sunnyvale, a very experienced programmer that created the JSON language. Before YUI compressor came out, I used JSMin for JavaScript compression.

Packing javascript using Dean Edwards’ Packer (specifically using the base64 encode) is not recommended, I don’t wannna provide the link to it here, 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.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Technorati
  • Twitter
  • Yahoo! Bookmarks

  1. No comments yet.
(will not be published)