diff --git a/includes/common.inc b/includes/common.inc
index 28e6f6980c8b29764483abef91153ae18bec8892..373eb645d36f411765dcc098184cde6df27a955b 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3669,7 +3669,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
         $js_element['#value_prefix'] = $embed_prefix;
         $js_element['#value'] = $item['data'];
         $js_element['#value_suffix'] = $embed_suffix;
-        $output .= theme('html_tag', array('element' => $js_element));
+        $processed[$index++] = theme('html_tag', array('element' => $js_element));
         break;
 
       case 'file':
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index de4861389a7d3d7ef1581ee344109f6a1ca0f20a..68b99f7a1cc9cedf3466b63181db53b9519a1808 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1149,6 +1149,7 @@ class JavaScriptTestCase extends DrupalWebTestCase {
     drupal_add_js('(function($){alert("Weight -8 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
     drupal_add_js('(function($){alert("Weight -8 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
     drupal_add_js('(function($){alert("Weight -8 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
+    drupal_add_js('http://example.com/example.js?Weight -5 #1', array('type' => 'external', 'scope' => 'footer', 'weight' => -5));
     drupal_add_js('(function($){alert("Weight -8 #4");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
     drupal_add_js('(function($){alert("Weight 5 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));
     drupal_add_js('(function($){alert("Weight 0 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
@@ -1159,6 +1160,7 @@ class JavaScriptTestCase extends DrupalWebTestCase {
       "-8 #2",
       "-8 #3",
       "-8 #4",
+      "-5 #1", // The external script.
       "0 #1",
       "0 #2",
       "0 #3",