If you ever opened and looked inside any jQuery library file, you must have seen that it has no space between its lines. It is unusual for most of us who generally code line by line that make it comfortable to read. What I found is it looks like reading an article with no meaning :).
So, what is the reason for jQuery's developers to make it like that? Would not it be convenient if it was written line by line?
It's minified. It makes the file smaller, meaning faster websites.
All of the code is available in two formats:
- Compressed (which allows you to have a significantly smaller file size) and
- Uncompressed (good for debugging and to understand what is behind the magic).
From Downloading jQuery. A typical Software Engineering practice is to use full versions of code for development, and minified versions in production.
That's because it is minified. Line by line would also include a lot of spaces and new lines and because of that it would take more file size.
More file size = more traffic and there is your reason.
Minimizing files saves traffic. When you've got a big website, you should do the same to your code.
Here is a nice open source project for you which does it: http://code.google.com/p/minify/
This is because they want to shorten the library! There are two versions:
Development which is coded as you mentioned
Production which is shorter and has less Size
See Minification
It's minified, to download faster.
You can read the uncompressed code here: http://code.jquery.com/jquery-1.7.1.js
Example:
function add(value1, value2)
{
return value1 + value2;
}
function a(b,c){return b+c;}
Functions add
and a
perform the same operation and have the same result, but a
requires fewer bytes to express and as a result needs less storage space. Downloading the file is consequently faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With