diff --git a/includes/common.inc b/includes/common.inc index 8575844..b9ef33c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -4087,10 +4087,11 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS } } - $output = ''; + $output = $browser_output = ''; // The index counter is used to keep aggregated and non-aggregated files in // order by weight. $index = 1; + $browsers = array(); $processed = array(); $files = array(); $preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')); @@ -4165,6 +4166,10 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS case 'file': $js_element = $element; + if (isset($item['browsers'])) { + $browsers[] = $item; + continue; + } if (!$item['preprocess'] || !$preprocess_js) { if ($item['defer']) { $js_element['#attributes']['defer'] = 'defer'; @@ -4213,10 +4218,19 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS } } } + if (!empty($browsers)) { + foreach ($browsers as $item) { + $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?'; + $js_element['#attributes']['src'] = file_create_url($item['data']) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME); + $js_element['#browsers'] = $item['browsers']; + $js_element['#type'] = 'html_tag'; + $browser_output .= drupal_render($js_element); + } + } // Keep the order of JS files consistent as some are preprocessed and others are not. // Make sure any inline or JS setting variables appear last after libraries have loaded. - return implode('', $processed) . $output; + return $browser_output . implode('', $processed) . $output; } /**