September 2018
Intermediate to advanced
764 pages
20h 6m
English
Asynchronous Module Definition (AMD) is the most popular module specification that implements asynchronous module loading. AMD is actually an early fork of CommonJS, and also uses the require and exports syntax.
Just as there are module bundlers for CommonJS modules, there are module loaders for AMD modules. These tools are called loaders because they load the modules from the client directly. The most popular module loader is Require.js. Require.js provides you with a define function, which you can use to define your module. You can pass in a list of dependencies as its first argument. Let's look at an example:
// greeter.jsdefine(function () { function helloWorld(name) { process.stdout.write(`hello ${name}!\n`) }; return ...Read now
Unlock full access