Index: /CKEditor/branches/prototype/_source/core/config.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/config.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/core/config.js	(revision 2336)
@@ -134,7 +134,7 @@
 	 * @default 'editingblock,elementspath,sourcearea,toolbar,wysiwygarea'
 	 * @example
-	 * config.plugins = 'editingblock,toolbar,wysiwygarea';
+	 * config.plugins = 'elementspath,toolbar,wysiwygarea';
 	 */
-	plugins : 'basicstyles,button,editingblock,elementspath,htmldataprocessor,htmlwriter,selection,sourcearea,toolbar,wysiwygarea',
+	plugins : 'basicstyles,button,elementspath,htmldataprocessor,sourcearea,toolbar,wysiwygarea',
 
 	/**
Index: /CKEditor/branches/prototype/_source/core/editor.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/editor.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/core/editor.js	(revision 2336)
@@ -152,8 +152,7 @@
 				for ( var m = 0 ; m < methods.length ; m++ )
 				{
-					for ( var i = 0 ; i < plugins.length ; i++ )
+					for ( var pluginName in plugins )
 					{
-						var pluginName = plugins[ i ];
-						var plugin = CKEDITOR.plugins.get( pluginName );
+						var plugin = plugins[ pluginName ];
 						if ( plugin && plugin[ methods[ m ] ] )
 							plugin[ methods[ m ] ]( editor, CKEDITOR.plugins.getPath( pluginName ) );
Index: /CKEditor/branches/prototype/_source/core/pluginDefinition.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/pluginDefinition.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/core/pluginDefinition.js	(revision 2336)
@@ -33,4 +33,16 @@
  * @constructor
  * @example
+ */
+
+/**
+ * A list of plugins that are required by this plugin. Note that this property
+ * doesn't guarantee the loading order of the plugins.
+ * @name CKEDITOR.pluginDefinition.prototype.requires
+ * @type Array
+ * @example
+ * CKEDITOR.plugins.add( 'sample',
+ * {
+ *     requires : [ 'button', 'selection' ]
+ * });
  */
 
Index: /CKEditor/branches/prototype/_source/core/plugins.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/plugins.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/core/plugins.js	(revision 2336)
@@ -34,2 +34,43 @@
 	'_source/' +	// @Packager.RemoveLine
 	'plugins/', 'plugin' );
+
+CKEDITOR.plugins.load = CKEDITOR.tools.override( CKEDITOR.plugins.load, function( originalLoad )
+	{
+		return function( name, callback, scope )
+		{
+			var allPlugins = {};
+
+			var loadPlugins = function( names )
+			{
+				originalLoad.call( this, names, function( plugins )
+					{
+						CKEDITOR.tools.extend( allPlugins, plugins );
+
+						var requiredPlugins = [];
+						for ( var pluginName in plugins )
+						{
+							var plugin = plugins[ pluginName ],
+								requires = plugin && plugin.requires;
+
+							if ( requires )
+							{
+								for ( var i = 0 ; i < requires.length ; i++ )
+								{
+									if ( !allPlugins[ requires[ i ] ] )
+										requiredPlugins.push( requires[ i ] );
+								}
+							}
+						}
+
+						if ( requiredPlugins.length )
+							loadPlugins.call( this, requiredPlugins );
+						else
+							callback.call( scope || window, allPlugins );
+					}
+					, this);
+
+			};
+
+			loadPlugins.call( this, name );
+		};
+	});
Index: /CKEditor/branches/prototype/_source/core/resourcemanager.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/resourcemanager.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/core/resourcemanager.js	(revision 2336)
@@ -164,11 +164,12 @@
 	{
 		// Ensure that we have an Array of names.
-		var names = CKEDITOR.tools.isArray( name ) ? name : [ name ];
-		var total = names.length;
+		var names = CKEDITOR.tools.isArray( name ) ? name : name ? [ name ] : [],
+			total = names.length,
+			resources = {};
 
 		// Nothing to load, just call the callback.
 		if ( !total )
 		{
-			callback.call( scope || window, names );
+			callback.call( scope || window, resources );
 			return;
 		}
@@ -181,5 +182,5 @@
 		{
 			if ( ++callback._loaded == callback._total )
-				callback.call( scope || window, names );
+				callback.call( scope || window, resources );
 		};
 
@@ -190,6 +191,6 @@
 		{
 			// Calculate the plugin script path.
-			var path = this.externals[ name ] || ( this.basePath + name + '/' );
-			var filePath = CKEDITOR.getUrl( path + this.fileName + '.js' );
+			var path = this.externals[ name ] || ( this.basePath + name + '/' ),
+				filePath = CKEDITOR.getUrl( path + this.fileName + '.js' );
 
 			// Load the plugin script.
@@ -201,4 +202,6 @@
 					loaded[ name ] = path;
 
+					resources[ name ] = this.get( name );
+
 					// Check all callbacks that were waiting for this
 					// resource.
@@ -207,5 +210,5 @@
 
 					delete waitingList[ name ];
-				});
+				}, this);
 		};
 
@@ -215,16 +218,22 @@
 			name = names[ i ];
 
-			// If not loaded already.
-			if ( name && !loaded[ name ] && !this.registered[ name ] )
+			if ( name && typeof resources[ name ] == 'undefined' )
 			{
-				var waitingInfo = waitingList[ name ] || ( waitingList[ name ] = [] );
-				waitingInfo.push( callback );
-
-				// If this is the first call for it, go ahead loading.
-				if ( waitingInfo.length == 1 )
-					loadPlugin.call( this, name );
+				resources[ name ] = this.get( name );
+
+				// If not loaded already.
+				if ( !loaded[ name ] && !this.registered[ name ] )
+				{
+					var waitingInfo = waitingList[ name ] || ( waitingList[ name ] = [] );
+					waitingInfo.push( callback );
+
+					// If this is the first call for it, go ahead loading.
+					if ( waitingInfo.length == 1 )
+						loadPlugin.call( this, name );
+
+					continue;
+				}
 			}
-			else
-				loadCheck( callback );
+			loadCheck( callback );
 		}
 	}
Index: /CKEditor/branches/prototype/_source/core/tools.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/tools.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/core/tools.js	(revision 2336)
@@ -201,4 +201,34 @@
 		};
 	})(),
+
+	/**
+	 * Creates a function override.
+	 * @param {Function} originalFunction The function to be overridden.
+	 * @param {Function} functionBuilder A function that returns the new
+	 *		function. The original function reference will be passed to this
+	 *		function.
+	 * @returns {Function} The new function.
+	 * @example
+	 * var example =
+	 * {
+	 *     myFunction : function( name )
+	 *     {
+	 *         alert( 'Name: ' + name );
+	 *     }
+	 * };
+	 *
+	 * example.myFunction = CKEDITOR.tools.override( example.myFunction, function( myFunctionOriginal )
+	 *     {
+	 *         return function( name )
+	 *             {
+	 *                 alert( 'Override Name: ' + name );
+	 *                 myFunctionOriginal.call( this, name );
+	 *             };
+	 *     });
+	 */
+	override : function( originalFunction, functionBuilder )
+	{
+		return functionBuilder( originalFunction );
+	},
 
 	/**
Index: /CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js	(revision 2336)
@@ -27,4 +27,6 @@
 CKEDITOR.plugins.add( 'elementspath',
 {
+	requires : [ 'selection' ],
+
 	init : function( editor, pluginPath )
 	{
Index: /CKEditor/branches/prototype/_source/plugins/htmldataprocessor/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/htmldataprocessor/plugin.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/plugins/htmldataprocessor/plugin.js	(revision 2336)
@@ -22,4 +22,6 @@
 CKEDITOR.plugins.add( 'htmldataprocessor',
 {
+	requires : [ 'htmlwriter' ],
+
 	init : function( editor, pluginPath )
 	{
Index: /CKEditor/branches/prototype/_source/plugins/htmlwriter/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/htmlwriter/plugin.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/plugins/htmlwriter/plugin.js	(revision 2336)
@@ -316,3 +316,3 @@
 };
 
-CKEDITOR.plugins.add( 'htmlwriter', {} );
+CKEDITOR.plugins.add( 'htmlwriter' );
Index: /CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js	(revision 2336)
@@ -27,4 +27,6 @@
 CKEDITOR.plugins.add( 'sourcearea',
 {
+	requires : [ 'editingblock' ],
+
 	init : function( editor, pluginPath )
 	{
Index: /CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js	(revision 2335)
+++ /CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js	(revision 2336)
@@ -62,4 +62,6 @@
 	CKEDITOR.plugins.add( 'wysiwygarea',
 	{
+		requires : [ 'editingblock' ],
+
 		init : function( editor, pluginPath )
 		{
Index: /CKEditor/branches/prototype/fckpackager.xml
===================================================================
--- /CKEditor/branches/prototype/fckpackager.xml	(revision 2335)
+++ /CKEditor/branches/prototype/fckpackager.xml	(revision 2336)
@@ -96,12 +96,12 @@
 		<File path="_source/plugins/basicstyles/plugin.js" />
 		<File path="_source/plugins/button/plugin.js" />
-		<File path="_source/plugins/editingblock/plugin.js" />
 		<File path="_source/plugins/elementspath/plugin.js" />
 		<File path="_source/plugins/htmldataprocessor/plugin.js" />
-		<File path="_source/plugins/htmlwriter/plugin.js" />
-		<File path="_source/plugins/selection/plugin.js" />
 		<File path="_source/plugins/sourcearea/plugin.js" />
 		<File path="_source/plugins/toolbar/plugin.js" />
 		<File path="_source/plugins/wysiwygarea/plugin.js" />
+		<File path="_source/plugins/selection/plugin.js" />
+		<File path="_source/plugins/htmlwriter/plugin.js" />
+		<File path="_source/plugins/editingblock/plugin.js" />
 		<File path="_source/themes/default/theme.js" />
 	</PackageFile>
