AMD is the normalized output of the module defined by REQUIREJS during the promotion process.
CMD is the normalized output of the module defined by SEAJS in the process of generalization.
Similar to the CommonJS modules/2.0 specification, is bravojs in the promotion process of the module definition of standardized output.
A lot more??
These specifications are intended for the modular development of JavaScript, especially on the browser side.
At present, the implementation of these norms can be achievedThe purpose of browser-side modularization development。
Difference:
1. For dependent modules, AMD isEarly Execution, CMD isdeferred execution。 However, starting from 2.0, Requirejs is also changed to be deferred (depending on the way it is written and handled differently). CMD respected as lazy as possible.
2. CMD respectedrely on the nearest, AMD respectedrelying on the predecessor。 Look at the code:
Cmd
Define (function (Require, exports, module) {
var a = require ('./a ')
A.dosomething ()
100 lines are omitted here
var B = require ('./b ')//dependency can be written near
B.dosomething ()
// ...
})
The default recommended by AMD is
define (['./a ', './b '), function (A, B) {//dependencies must be written at the beginning.
A.dosomething ()
100 lines are omitted here
B.dosomething ()
...
})
While AMD supports the syntax of CMD, it also supports passing require as a dependency, but Requirejs's author defaults to the preferred notation, which is the default definition of the module in the official document.
3. AMD's API default isone when multiple use, the CMD API is strictly differentiated and respectedSingle Responsibility。 For example, AMD, require global require and local require, are called require. In CMD, there is no global require, but according to the completeness of the module system, provide seajs.use to realize the loading and starting of the module system. CMD, each API isSimple and pure。
4. There are also some details of the difference, the specific definition of the specification is good, not much to say.
In addition, SEAJS and Requirejs differences, you can refer to:https://github.com/seajs/seajs/issues/277
The difference between CMD and AMD (JS Modular)