Last updated July 1, 2012.

What is being done in Drupal 7

Current Drupal JS Workflow (2).png


What is AMD?

AMD stands for Asynchronous Module Definition, it specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded. To read more about this Javascript specification, go to
AMD is the browser-friendly version of CommonJS. It will be possible to use both CommonJS and AMD format by the end, it's just a little easier to start with AMD.

Advantages of getting AMD into Drupal

  • Follow a battle-tried module definition and implementation
  • Dependency handling and resolution between scripts
  • Speed up page load: scripts can be loaded asynchronously
  • Reduce JS footprint: only load what you need
  • Make on-demand loading easy
  • Avoid the use of globals

How to get AMD into Drupal?

  • Modify Drupal API (hook_library_info) to handle enough meta data for AMD configuration
  • Add all the informations to library_info for core JS files
  • Use RequireJS as a first implementation of an AMD loader
  • Use AMD-style configuration to replace Drupal.settings
  • Make it pluggable so people don't get stuck with AMD or RequireJS
  • Make a basic PHP version of r.js (NodeJS/Rhino preprocessor/optimizer)

Drupal with AMD and Assetic - The AMD picture.png