The organization of your files depends on the type of the project, size, existing modules, etc ... Try to identify if your javascripts functions can be grouped in different files, for example:
In a project you have:
- Utility functions for string, date, and numbers.
- Data validation functions
- Processing functions
Here your structure may look like:
< your project
< js
< utils
< stringUtils.js
< numberUtils.js
< dateUtils.js
< validation
< js
< js
< process
< js
< .... js
Thus, we group our files into different files and into different directories. The project was well divided and intuitive. It's just an example of organization for you to get an idea of how to build your structure.
EDIT: Managers
Depending on the structure of your project, you may want to use file managers to make your work easier. On some projects where I use AngularJS
, I usually use RequireJS
. RequireJS
manages all dependencies on .js files by importing them when necessary.
Read about it here . This link also talks about optimization .