AMD and CMD

Source: Internet
Author: User

This is some of the information collected online and some of your own views about AMD and CMD

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.
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 specifications can achieve the purpose of browser-side modular development.

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. :

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 defaults to one when multiple uses, the CMD API is strictly differentiated, advocating a single 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 is simple and pure.

AMD and CMD

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.