Chapter 4. Modular Code
As your project's code grows, the number of scripts in the project will be more and more, incrementing script-loading complexity. The classic way to load JavaScript files is to write a<script>
tags for every script you have, but you have to do it in the right order; if you don't, your code could stop working. That's not an efficient way for medium-size projects.
What happens if you forget the order of loading? What if you make a refactorization on the code and the order of the script changes? It will be a pain to fix it and keep track of all the code and its dependencies.
This problem has been addressed in different ways. One is to create a module syntax to create, load, and declare explicitly the dependencies of modules; the syntax is called AMD (Asynchronous Module Definition). The AMD modules define a list of module dependencies, and the code inside the module will be executed only after the dependencies are fully loaded.
The dependencies...