﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
23285	Implement an AMD JavaScript loader in WordPress	auniquename		"AMD = Asynchronous Module Definition

See comment: http://core.trac.wordpress.org/ticket/22896#comment:29

I think this is a must for the future viability of WordPress and plugins written for it.

Multiple versions of JavaScript libraries are a fact of life and we have to deal with it somehow.

If WordPress provides the framework for the use of multiple versions of JavaScript libraries then a lot of the problems we see with WordPress now will be a thing of the past.

This represents a major re-think of the current WordPress JavaScript loading paradigm, but I think it is necessary and would be well worth it.

I'm not a terribly advanced developer, and there might be better solutions out there or others to come, but for now, I think this is the way to go.

Example:

http://requirejs.org/docs/why.html

http://requirejs.org/docs/whyamd.html

https://github.com/amdjs/amdjs-api/wiki/AMD

It does not have to be RequireJS, but it seems the most mature and popular of the implementations.

From the unminified jQuery source:
{{{
// Expose jQuery as an AMD module, but only for AMD loaders that
// understand the issues with loading multiple versions of jQuery
// in a page that all might call define(). The loader will indicate
// they have special allowances for multiple jQuery versions by
// specifying define.amd.jQuery = true. Register as a named module,
// since jQuery can be concatenated with other files that may use define,
// but not use a proper concatenation script that understands anonymous
// AMD modules. A named AMD is safest and most robust way to register.
// Lowercase jquery is used because AMD module names are derived from
// file names, and jQuery is normally delivered in a lowercase file name.
// Do this after creating the global so that if an AMD module wants to call
// noConflict to hide this version of jQuery, it will work.
if ( typeof define === ""function"" && define.amd && define.amd.jQuery ) {
	define( ""jquery"", [], function () { return jQuery; } );
}
}}}

Note: '''multiple versions of jQuery'''"	feature request	new	normal	Awaiting Review	General		normal			bpetty
