Index: wp-includes/class.wp-scripts.php
===================================================================
--- wp-includes/class.wp-scripts.php	(revision 10123)
+++ wp-includes/class.wp-scripts.php	(working copy)
@@ -19,6 +19,7 @@
 class WP_Scripts extends WP_Dependencies {
 	var $base_url; // Full URL with trailing slash
 	var $default_version;
+	var $print_once_done = false;
 
 	function __construct() {
 		do_action_ref_array( 'wp_default_scripts', array(&$this) );
@@ -44,25 +45,6 @@
 
 		echo "<script type='text/javascript'>\n";
 		echo "/* <![CDATA[ */\n";
-		echo "function convertEntities(o) {\n";
-		echo "	var c = function(s) {\n";
-		echo "		if (/&[^;]+;/.test(s)) {\n";
-		echo "			var e = document.createElement('div');\n";
-		echo "			e.innerHTML = s;\n";
-		echo "			return !e.firstChild ? s : e.firstChild.nodeValue;\n";
-		echo "		}\n";
-		echo "		return s;\n";
-		echo "	}\n";
-		echo "	if ( typeof o === 'string' ) {\n";
-		echo "		return c(o);\n";
-		echo "	} else if ( typeof o === 'object' ) {\n";
-		echo "		for (var v in o) {\n";
-		echo "			if ( typeof o[v] === 'string' )\n";
-		echo "				o[v] = c(o[v]);\n";
-		echo "		}\n";
-		echo "	}\n";
-		echo "	return o;\n";
-		echo "};\n";
 		echo "\t$object_name = {\n";
 		$eol = '';
 		foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {
@@ -81,6 +63,8 @@
 		if ( !parent::do_item($handle) )
 			return false;
 
+		$this->print_once();
+
 		$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
 		if ( isset($this->args[$handle]) )
 			$ver .= '&amp;' . $this->args[$handle];
@@ -122,4 +106,35 @@
 			$this->to_do = apply_filters( 'print_scripts_array', $this->to_do );
 		return $r;
 	}
+
+	function print_once() {
+		if ( $this->print_once_done )
+			return;
+
+		echo "<script type='text/javascript'>\n";
+		echo "/* <![CDATA[ */\n";
+		echo "function convertEntities(o) {\n";
+		echo "	var c = function(s) {\n";
+		echo "		if (/&[^;]+;/.test(s)) {\n";
+		echo "			var e = document.createElement('div');\n";
+		echo "			e.innerHTML = s;\n";
+		echo "			return !e.firstChild ? s : e.firstChild.nodeValue;\n";
+		echo "		}\n";
+		echo "		return s;\n";
+		echo "	}\n";
+		echo "	if ( typeof o === 'string' ) {\n";
+		echo "		return c(o);\n";
+		echo "	} else if ( typeof o === 'object' ) {\n";
+		echo "		for (var v in o) {\n";
+		echo "			if ( typeof o[v] === 'string' )\n";
+		echo "				o[v] = c(o[v]);\n";
+		echo "		}\n";
+		echo "	}\n";
+		echo "	return o;\n";
+		echo "};\n";
+		echo "/* ]]> */\n";
+		echo "</script>\n";
+
+		$this->print_once_done = true;
+	}
 }
