diff -u b/includes/common.inc b/includes/common.inc --- b/includes/common.inc +++ b/includes/common.inc @@ -86,11 +86,6 @@ define('JS_THEME', 100); /** - * The default group for JavaScript settings added to the page. - */ -define('JS_SETTING', 200); - -/** * Error code indicating that the request exceeded the specified timeout. * * @see drupal_http_request() @@ -4056,15 +4051,15 @@ ), 'type' => 'setting', 'scope' => 'header', - 'group' => JS_SETTING, + 'group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => 0, - 'browsers' => array(), ), 'misc/drupal.js' => array( 'group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => 0, + 'browsers' => array(), ), 'misc/drupal.js' => array( 'data' => 'misc/drupal.js', @@ -4272,6 +4267,10 @@ ), ); + // Make sure JS setting variables appear last. + // @todo In Drupal 8, add a large weight JS_SETTING group to accomplish this. + $setting_elements = array(); + // Loop through each group. foreach ($elements['#groups'] as $group) { // If a group of files has been aggregated into a single file, @@ -4319,12 +4318,17 @@ break; } - $elements[] = $element; + if ($item['type'] == 'setting') { + $setting_elements[] = $element; + } + else { + $elements[] = $element; + } } } } - return $elements; + return array_merge($elements, $setting_elements); } /**