JQuery has two versions for download, one is Production (19KB, Minified and Gzipped), and the other is Development (120KB, Uncompressed Code).
Now the compact 19kb version, if you download it, you will see is still a javascript executable code. How did they compactify it? And how can I 'minify' my code like that too?
There’s a nice comparison of JavaScript compressors you should take a look at.
Along with minifying you can base64 encode it too. It makes your file much more compressed. I'm sure you have seen js files that are wrapped inside an eval() function with parameters (p,a,c,k,e,r) passed. I read it in this article How to Minify a Javascript File?
Google just made available a javascript compiler that can minify your code, elimiated dead code branches and more optimizations.
google javascript compiler
Regards
K
There are currently 2 ways of minifying your code:
http://yui.github.io/yuicompressor/
Many such tools are available for Node and npm as well - it's good practice to automate the mnification of Javascript with Grunt.
http://www.modify-anything.com/
I have written a tiny script which calls a API to get your script minified, check it out:
Usage:
I recently needed to perform the same task. While the compressors listed at The JavaScript CompressorRater do a great job and the tool is very useful, the compressors were not playing nice with some jQuery code I am using ($.getScript and jQuery.fn checks). Even the Google Closure Compressor choked on the same lines. While I could have eventually ironed out the kinks it was far to much squinting to do constantly.
The one that finally worked without issue was UglifyJS (thanks @Aries51), and the compression was only slightly less than all the others. And similar to Google it has a HTTP API. Packer is also nice and has language implementation in Perl, PHP, and .NET.