Asynchronous module definition
   HOME

TheInfoList



OR:

Asynchronous module definition (AMD) is a
specification A specification often refers to a set of documented requirements to be satisfied by a material, design, product, or service. A specification is often a type of technical standard. There are different types of technical or engineering specificati ...
for the programming language
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, of ...
. It defines an
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
(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 Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
. For production and deployment, developers can
concatenate In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalisations of concatenat ...
and minify JavaScript modules based on an AMD API into one file, the same as traditional JavaScript. AMD provides some
CommonJS CommonJS is a project with the goal to establish conventions on the module ecosystem for JavaScript outside of the web browser. The primary reason for its creation was a major lack of commonly accepted forms of JavaScript module units which could ...
interoperability. It allows for using a similar and interface in the code, although its own interface is more basal and preferred. The AMD specification is implemented by
Dojo Toolkit Dojo Toolkit (stylized as dōjō toolkit) is an open-source modular JavaScript library (or more specifically JavaScript toolkit) designed to ease the rapid development of cross-platform, JavaScript/Ajax-based applications and web sites. It was ...
, RequireJS, and other libraries.


References


External links

*
Why AMD? (Require.js)

Dojo Introduction to AMD

Writing Modular JavaScript With AMD, CommonJS & ES Harmony
{{ECMAScript JavaScript Application programming interfaces Web development