Last updated July 1, 2012.
What is being done in Drupal 7
What is AMD?
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)