What's the difference between jquery.js and jquery.min.js? – Dev

The best answers to the question “What's the difference between jquery.js and jquery.min.js?” in the category Dev.

QUESTION:

What is the difference between jquery.min.js and jquery.js?

Which one has support for all functions?

ANSWER:

Both support the same functions. jquery.min.js is a compressed version of jquery.js (whitespaces and comments stripped out, shorter variable names, …) in order to preserve bandwidth. In terms of functionality they are absolutely the same. It is recommended to use this compressed version in production environment.

ANSWER:

They are both the same functionally but the .min one has all unnecessary characters removed in order to make the file size smaller.

Just to point out as well, you are better using the minified version (.min) for your live environment as Google are now checking on page loading times. Having all your JS file minified means they will load faster and will score you more brownie points.

You can get an addon for Mozilla called Page Speed that will look through your site and show you all the .JS files and provide minified versions (amongst other things).

ANSWER:

Jquery.min.js is nothing else but compressed version of jquery.js.
You can use it the same way as jquery.js, but it’s smaller, so in production you should use minified version and when you’re debugging you can use normal jquery.js version.
If you want to compress your own javascript file you can these compressors:

  • http://developer.yahoo.com/yui/compressor/
  • http://code.google.com/intl/pl-PL/closure/compiler/
  • http://jscompress.com/

Or just read topis on StackOverflow about js compression 🙂 :

  • Best JavaScript compressor
  • What do you use to minimize and compress JavaScript libraries?

ANSWER:

  • jquery.js = Pretty and easy to read 🙂 Read this one.

  • jquery.min.js = Looks like jibberish! But has a smaller file size. Put this one on your site.

Both are the same in functionality. The difference is only in whether it’s formatted nicely for readability or compactly for smaller file size.

Specifically, the second one is minified, a process which involves removing unnecessary whitespace and shortening variable names. Both contribute to making the code much harder to read: the removal of whitespace removes line breaks and spaces messing up the formatting, and the shortening of variable names (including some function names) replaces the original variable names with meaningless letters.

All this is done in such a way that it doesn’t affect the way the code behaves when run, in any way. Notably, the replacement/shortening of variable and function names is only done to names that appear in a local scope where it won’t interfere with any other code in other scripts.