Why jQuery library scripts do not have space between lines?

If you've ever opened and looked at any jQuery library file, you must have seen that it has no space between its lines. This is unusual for most of us, which are usually built sequentially, which makes it easy to read. What I found seems to be reading an article without meaning :).

So what is the reason why jQuery developers do it this way? Wouldn't it be convenient if it was written line by line?

+5
source share
4 answers

It is minified . This makes the file smaller, which means faster websites.

All code is available in two formats:

  • Compressed (which allows you to have a significantly smaller file size) and
  • ( , ).

jQuery. .

+6

minified, .

: http://code.jquery.com/jquery-1.7.1.js

:

function add(value1, value2)
{ 
   return value1 + value2;
}

function a(b,c){return b+c;}

add a , a , . .

+2

, . , - .

= , .

Minimizing files saves traffic. When you have a large site, you must do the same with your code.

Here is a good open source project for you that does this: http://code.google.com/p/minify/

+2
source

This is because they want to cut the library! There are two versions:

Development that is coded as you mentioned

Production that is shorter and smaller

See the Minimize section.

+2
source

All Articles