This article is referenced from: https://www.cnblogs.com/chenguangliang/p/5856701.html
1, CommonJS
Nodejs is the implementation of COMMONJS specification, Webpack is also in the form of Commonjs to write. node. JS uses the JavaScript language for server-side programming.
2. AMD
Based on the COMMONJS specification of the Nodejs out, the service-side module concept has been formed, very naturally, we want the client module. And it is best to be compatible, a module without modification, both server and browser can be run. However, due to a significant limitation, the COMMONJS specification does not apply to the browser environment .
var math = require (' math '); Math.add (2, 3);
The second line, Math.add (2, 3), runs after the first line of require (' math '), so it must wait until the math.js load is complete. That is, if the load time is long, the entire application will stop there and so on. you'll notice that require
it's synchronized.
This is not a problem on the server side, because all the modules are stored on the local hard disk, can be loaded synchronously, waiting time is the hard disk read time. However, for the browser, this is a big problem, because the modules are placed on the server side, the waiting time depends on the speed of the network, it may take a long time, the browser is in "Suspended animation" status.
As a result, the browser-side module cannot be "synchronous-loaded" (synchronous) and can only take "asynchronous load" (asynchronous). This is the background to the birth of the AMD specification.
AMD is the abbreviation for "Asynchronous module definition", meaning "async module definition". It loads the module asynchronously, and the module's load does not affect the execution of the statement behind it. All statements that rely on this module are defined in a callback function that will not run until the load is complete.
3, CMD
The CMD is highly dependent on the nearest, AMD is highly dependent on the predecessor.
CommonJS, AMD, and CMD differences