Managing JavaScript complexity in a large project

What should I use to manage the growing number of JavaScript files in my application?

We are creating a django application with several applications. Each application has different functionality and should be presented in three different modes (PC, tablet, mobile). A lot of things are happening in JavaScript: managing data received from the server, processing user events, embedding HTML fragments, and loading subcomponents. Some functionality is shared between applications and viewing modes, but it often makes sense to write certain functions (for example, move the mouse cursor and click on events that may have to be processed differently on the PC’s layout or on the tablet’s tablet), so we group this into files based on app / layout / function.

To the point, we used a flat naming file structure to distinguish between file types:

ui.common.js
ui.app1.pc.handlers.js
ui.app1.pc.domManupulators.js
ui.app1.tablet.js
ui.app2.pc.js 
...

However, now that the number of applications (and angular cases) is growing, this method is quickly becoming unusual (we are approaching 20+ files and expect that maybe 40+ by the time we finish), so that we put everything in such directories:

js/
  common/
    core1.js
    ajax2.js
  app1/
    tablet.js
    pc.js
  app2/
    mobile.js
    ...

I looked at JavaScriptMVC to help with this. Although it offers useful tools, it doesn't seem to have anything to improve the management of our gigantic JavaScript library. We will soon expand our development team, and technical support for the code is very important.

Is there anything that can make our life easier? Are there any habits / rules of thumb that you use in your work that could facilitate this?

+5
source share
2 answers

Backbone.js javascript MVC. , , , .

.

+2

, (, ). , , , , .

+1

All Articles