Generated by GPT-5-mini| AMD (Asynchronous Module Definition) | |
|---|---|
| Name | AMD (Asynchronous Module Definition) |
| Developer | Various |
| Released | 2010s |
| Programming language | JavaScript |
| Platform | Web browsers, Node.js |
| License | MIT/BSD/various |
AMD (Asynchronous Module Definition) is a specification for defining JavaScript modules in a way that supports asynchronous loading and dependency management in client-side environments. It aims to address script loading, dependency resolution, and modular organization for large web applications developed with libraries and frameworks.
AMD defines an asynchronous, callback-oriented module format that separates module definition from module loading, enabling non-blocking retrieval of code for projects that integrate libraries such as jQuery, Dojo Toolkit, Backbone.js, React and AngularJS. The design complements module systems used by CommonJS implementations like Node.js while targeting browsers and environments where network latency and script ordering matter, often in conjunction with build tools such as Grunt (software), Gulp (software), Webpack and Browserify. AMD influenced or coexisted with initiatives from organizations including the OpenJS Foundation, Mozilla Foundation, Google, Microsoft and communities around ECMAScript standards.
AMD emerged from discussions among developers and projects during debates about modularity in client-side JavaScript, where contributors from Dojo Toolkit, RequireJS, jQuery plugin ecosystems, and developers active in GitHub repositories proposed formats to avoid the pitfalls observed with older patterns used by Yahoo! and Google-hosted libraries. The goal was to improve maintainability in single-page applications built with frameworks like Ember.js, AngularJS, and Backbone.js while addressing issues experienced by teams at companies such as Facebook, Twitter, LinkedIn, Netflix, PayPal and Amazon (company). Influences included discussions surrounding ECMAScript 6 module proposals and standards work in organizations such as TC39 and research by engineers at Mozilla and Microsoft Research.
The AMD API centers on two principal primitives implemented by loaders like RequireJS and curl.js: a define function to declare modules and a require function to request modules asynchronously. Core concepts include dependency arrays, factory callbacks, anonymous modules, named modules, and plugin mechanisms similar to extension points used by Grunt (software) plugins or Gulp (software) tasks. AMD modules interact with bundlers and optimizers including r.js (RequireJS optimizer), which align with practices from teams at Yahoo! and AOL for offline concatenation and minification. The specification influenced module semantics discussed within TC39 and relates to other module patterns used by CommonJS, UMD, and the later ECMAScript modules standardized in ECMAScript 2015.
Prominent AMD loaders and implementations include RequireJS, curl.js, and loader components embedded in frameworks like Dojo Toolkit. Libraries and tools that adopted or provided bridges to AMD semantics include jQuery, Lodash, Underscore.js, Backbone.js, React integrations, and adapters developed by organizations such as Microsoft for Visual Studio toolchains. Build and optimization tools that understand AMD include r.js, Webpack, Rollup, and integrations with Grunt (software) and Gulp (software), used by development teams at GitHub, Atlassian, Mozilla, Google and Facebook.
Common usage patterns show AMD modules defined with define([...], function(...){ ... }) and applications bootstrapped via require([...], function(...) { ... }). Patterns include lazy loading for route-based code splitting in projects inspired by React router implementations, plugin-based loaders for text or JSON resources as seen in RequireJS plugins, and integration with template engines used by Handlebars.js and Mustache (template system). AMD was used in production by teams at Mozilla for some browser-extension code, by Yahoo! for widget-based sites, and by enterprise projects at IBM, Oracle, SAP and Adobe Inc. to modularize front-end assets.
AMD's asynchronous loader model reduces blocking behavior in browsers such as Chrome (web browser), Firefox, Safari, Edge and Internet Explorer by deferring script execution until dependencies are resolved, which can improve perceived performance on sites at Google scale or services run by Netflix and LinkedIn. However, runtime HTTP requests per module can increase overhead on high-latency networks unless mitigated by bundlers and CDNs like those used by Akamai Technologies, Cloudflare, Fastly and Amazon CloudFront. Optimizers such as r.js and packagers like Webpack and Rollup are commonly used to produce concatenated artifacts compatible with legacy loaders and to support caching strategies employed by Akamai Technologies and Cloudflare.
Critics noted that AMD's asynchronous callbacks and dependency arrays add verbosity and a cognitive burden compared with ECMAScript modules and import/export syntax standardized in ECMAScript 2015, prompting migrations in projects at Google, Facebook, Microsoft, and Mozilla to native modules. Alternatives and related patterns include CommonJS used by Node.js, UMD wrappers for cross-environment compatibility, and module bundlers such as Webpack and Rollup (software), which often prefer static analysis over runtime formats. Debates among contributors from TC39, W3C working groups, and large engineering teams at Apple Inc., Google, Microsoft and Facebook shaped the eventual adoption of standardized module semantics.