Module loading
Modules concern code organization, which is how the functionalities of an application are distributed in units that simplify reusability, maintainability, and understandability of the code. The concept of module itself does not concern how it is loaded into the execution environment. Usually, this should be a concern of the runtime engine hosting the application. However, module loading plays an important role in JavaScript, as we will see in this section.
Modules, scripts, and files
In the examples we have shown so far, we have not said where the modules are. Until now, we talked about modules as units of code with private and public parts, but where do they live in an application?
In general, one or more modules can be in the same container of the entire application. For example, we can imagine a JavaScript application composed of many modules, all stored in a single file or in a single Web page. For nontrivial applications usually this is not a clever solution, at least during...