Differences and usage scenarios of alamedajs/almondjs/requirejs

Both almondjs and alamedajs are lightweight AMD loaders for some developers who use requirejs lightly. The basic API remains the same.

 

* Functional completeness of the three: requirejs>alamedajs>almondjs

* The size of the file: requirejs>alamedajs>almondjs

 

alamedajs

 

1. It is not compatible with lower versions of browsers. Its target compatible browsers are chrome, safari, IE10+ and other modern standard browsers. It does not support ie<=9, because the source code is written in ES5 and uses some ES5 features, such as Array.isArray, forEach, etc.

2. A lot of compatible code is omitted, and some advanced APIs are used, so the total code size is reduced by about 35% compared to requirejs.

3. The source code uses Promise, so if you want to use alamedajs in IE10\11, you need to introduce a Promise polyfill or directly use almameda-prim, a version that supports Promise.

 

Usage scenario : Only projects that are compatible with standard browsers can be used instead of requirejs

 

almondjs

 

1. There is no built-in loader, and remote modules cannot be loaded

2. Because remote modules cannot be loaded, all modules of the project need to be packaged into a JS file

3. Only use requirejs.config once

4. Castrated some requirejs functions, such as require.toUrl, require.nameToUrl, etc.

5. Each module must have a module ID, because all modules will eventually be packaged into a file, which cannot be identified by the file name. This can be solved automatically by requirejs' optimization tool (r.js).

 

Usage scenario : A project that is purely packaged into a bundle file.

 

Summary: For the ultimate optimization of different projects, loaders with different castration degrees can be used to reduce bandwidth consumption and improve operating efficiency

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326946045&siteId=291194637