asynchronous module definition
{{Short description|Specification for JavaScript programming language}}
File:Asynchronous Module Definition overview vector.svg
Asynchronous module definition (AMD) is a specification for the programming language JavaScript. It defines an application programming interface (API) that defines code modules and their dependencies, and loads them asynchronously if desired. Implementations of AMD provide the following benefits:
- Website performance improvements. AMD implementations load smaller JavaScript files, and then only when they are needed.
- Fewer page errors. AMD implementations allow developers to define dependencies that must load before a module is executed, so the module does not try to use outside code that is not available yet.
In addition to loading multiple JavaScript files at runtime, AMD implementations allow developers to encapsulate code in smaller, more logically-organized files, in a way similar to other programming languages such as Java. For production and deployment, developers can concatenate and minify JavaScript modules based on an AMD API into one file, the same as traditional JavaScript.
AMD provides some CommonJS interoperability. It allows for using a similar {{code|exports}} and {{code|require()}} interface in the code, although its own {{code|define()}} interface is more basal and preferred.{{cite web |title=AMD specification |url=https://github.com/amdjs/amdjs-api |website=GitHub |publisher=Group for AMD JS Module API |access-date=28 October 2019 |date=28 October 2019}}
The AMD specification is implemented by Dojo Toolkit, RequireJS, and other libraries.
References
{{Reflist}}
External links
- {{official website|https://github.com/amdjs/amdjs-api}}
- [http://requirejs.org/docs/whyamd.html Why AMD? (Require.js)]
- [http://dojotoolkit.org/documentation/tutorials/1.10/modules/ Dojo Introduction to AMD]
- [http://addyosmani.com/writing-modular-js/ Writing Modular JavaScript With AMD, CommonJS & ES Harmony]
{{ECMAScript}}