The RequireJS framework
If you are serious about the organization of lots of JavaScript files and components, then you will be happy that ideas from dependency injection frameworks such as CDI and Spring have also made it in the world. Some professional organizations already rely on a small framework called RequireJS (http://requirejs.org/). The RequireJS framework is a JavaScript file and module loader. The framework has a built-in module script loader, which will improve the speed and quality of your code.
RequireJS implements the Asychronous Module Definition (AMD) specification for JavaScript (https://github.com/amdjs/amdjs-api/wiki/AMD). This specification defines a mechanism that in turn defines the modules and dependencies between modules and how they can be asynchronously loaded.
The AMD specification solves the critical issues where you have many JavaScript modules and define the multiple HTML script elements so as to load them, but then you find that each module had a dependency...