F
F
fujuxo2016-11-23 17:14:08
css
fujuxo, 2016-11-23 17:14:08

Why is it necessary to split the code into files?

Can anyone explain what are the cons of storing all js or css in one file?
I have logic on the frontend in jQuery, there are 8 thousand lines, everything is divided into objects and functions with clear names, the IDE allows you to conveniently "collapse" the code of the entire function / object into one line. so in the end I end up with 2 screens of code in a "collapsed" form. There are no problems with the search: everything is located within two pages and is well searched through the document search. So why should I split the code into files?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Snewer, 2016-11-23
@Snewer

Well, don’t break it if everything works and only you are developing

A
Andrey B., 2016-11-23
@andykov

Component / Modularity

D
Denis Ineshin, 2016-11-23
@IonDen

The code is divided into files for ease of development. In the end, the assembler will still glue everything into one file later.
1. The fact that you collapsed unnecessary sections of code using IDE tools is not an ideal and very limited solution.
In a large project, the code structure can have more than 1 nesting level, and it is impossible to implement such a structure by hiding unnecessary elements.
2. Switching between files is more convenient, because even one feature can be split into several files. The code will be cleaner, there will be no need to constantly scroll up and down an unknown distance. You can switch to another tab quickly with hotkeys.
3. Large files can slow down.

L
lukoie, 2016-11-23
@lukoie

What about file upload parallelism?
Sometimes it's better to have files loaded into several streams than to drag one. Although sometimes one request is better than several. So it depends on the specific tasks.

M
Michael, 2016-11-23
@springimport

Why do you need to break?
1. Broken files are easy to manipulate: leave as is or glue.
2. When developing, you can quickly open the desired module (for example). Or quickly see the changes in git.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question