function drupal_sort_css_js
Sorts CSS and JavaScript resources.
Callback for uasort() within:
This sort order helps optimize front-end performance while providing modules and themes with the necessary control for ordering the CSS and JavaScript appearing on a page.
Parameters
$a: First item for comparison. The compared items should be associative arrays of member items from drupal_add_css() or drupal_add_js().
$b: Second item for comparison.
See also
2 string references to 'drupal_sort_css_js'
- drupal_get_css in includes/
common.inc - Returns a themed representation of all stylesheets to attach to the page.
- drupal_get_js in includes/
common.inc - Returns a themed presentation of all JavaScript code for the current page.
File
-
includes/
common.inc, line 3298
Code
function drupal_sort_css_js($a, $b) {
// First order by group, so that, for example, all items in the CSS_SYSTEM
// group appear before items in the CSS_DEFAULT group, which appear before
// all items in the CSS_THEME group. Modules may create additional groups by
// defining their own constants.
if ($a['group'] < $b['group']) {
return -1;
}
elseif ($a['group'] > $b['group']) {
return 1;
}
elseif ($a['every_page'] && !$b['every_page']) {
return -1;
}
elseif (!$a['every_page'] && $b['every_page']) {
return 1;
}
elseif ($a['weight'] < $b['weight']) {
return -1;
}
elseif ($a['weight'] > $b['weight']) {
return 1;
}
else {
return 0;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.