AMD specifications are here:https://github.com/amdjs/amdjs-api/wiki/amd
The CMD specification is here:https://github.com/seajs/seajs/issues/242
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.
Difference:
1. For dependent modules, AMD is executed in advance and CMD is deferred. 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 is highly dependent on the nearest, AMD is highly dependent on the predecessor, for example:
//CMD is recommended by defaultDefinefunction(Require, exports, module) {varA = require ('./a ')) a.dosomething ()//100 lines are omitted here varb = require ('./b ')) //Reliance can be written nearb.dosomething () ...})//the default recommended by AMD isdefine (['./a ', './b '),function(A, b) {//dependence must be written right from the starta.dosomething ()//100 lines are omitted hereb.dosomething () ...})
It is worth mentioning that require also support the writing of CMD, but it seems that require more recommend this AMD default wording.
3. AMD's API default is
one when multiple use, the CMD API is strictly differentiated and respected
Single Responsibility。 For example, AMD, require global require and local require, are called require. In CMD, there is no global require, but it provides SEAJS according to the completeness of the module system.
UseTo enable the loading of the module system to start. CMD, each API is
Simple and pure。
4. There are also some details of the difference, the specific definition of the specification is good, not much to say.
JS Modular two specifications AMD and CMD