RequireJS – AMD viewmodels
RequireJS (http://requirejs.org/) is a library that you should have at least heard of already, if not used. This is still a book about Knockout, and if you are planning to use RequireJS in an application, you should read up on it first, but I will still give you a brief overview here.
An overview of RequireJS
RequireJS's purpose is to allow your code to be broken into modules that declare their dependencies so that they can be injected at runtime. This has several important benefits. As RequireJS loads your JavaScript, you don't have to include each script with a script
tag in your HTML. As RequireJS loads the scripts based on their dependencies, you don't have to worry about the order they are loaded in. As each module's dependencies are injected, the module can be tested easily with mocks. RequireJS also keeps all the objects it loads out of the global scope, which decreases the likelihood of namespace collisions in addition to being...