When we say an application is modular, we generally mean it’s composed of a set of highly decoupled, distinct pieces of functionality stored in modules. As you probably know, loose coupling facilitates easier maintainability of apps by removing dependencies where possible. When this is implemented efficiently, it’s quite easy to see how changes to one part of a system may affect another.
Instead, developers are left to fall back on variations of the module
or object literal patterns combined with
tags or a script loader. With many of these, module scripts are strung
together in the DOM with namespaces being described by a single global
object where it’s still possible to have name collisions. There’s also no
clean way to handle dependency management without some manual effort or
In this next part of the book, we’re going to look at how to use AMD (asynchronous module definition) modules and RequireJS to cleanly wrap units of code in your application into manageable modules. We’ll ...