Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Created February 7, 2014 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Greg-Boggs/8869659 to your computer and use it in GitHub Desktop.
Save Greg-Boggs/8869659 to your computer and use it in GitHub Desktop.
Group Drupal CSS
<?php
/**
* Implements hook_css_alter().
*/
function mymodule_css_alter(&$css) {
uasort($css, 'drupal_sort_css_js');
$i = 0;
foreach ($css as $name => $style) {
$css[$name]['weight'] = $i++;
$css[$name]['group'] = CSS_DEFAULT;
$css[$name]['every_page'] = FALSE;
}
}
?>
<?php
//if you have more than 4095 selectors here's the method to make two sheets for IE 8
uasort($css, 'drupal_sort_css_js');
$i = 0;
foreach ($css as $name => $style) {
$css[$name]['weight'] = $i++;
// Break grouping into two sets - CSS_SYSTEM, (-100) and the rest
if ($style['group'] == -100) {
$css[$name]['group'] = CSS_SYSTEM;
}
else {
$css[$name]['group'] = CSS_DEFAULT;
}
$css[$name]['every_page'] = FALSE;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment