Skip to content

Instantly share code, notes, and snippets.

@mavimo
Created December 30, 2017 18:19
Show Gist options
  • Save mavimo/a7f65924606d608c4a1f53e4234edb04 to your computer and use it in GitHub Desktop.
Save mavimo/a7f65924606d608c4a1f53e4234edb04 to your computer and use it in GitHub Desktop.
/**
 * Implements hook_css_alter().
 */
function THEME_NAME_css_alter(&$css) {
foreach ($css as &$style) {
 $style['weight'] += $style['group'];
 $style['group'] = CSS_DEFAULT;
 $style['every_page'] = TRUE;
 }
}
/**
 * Implements hook_js_alter().
 */
function THEME_NAME_js_alter(&$javascript) {
 foreach ($javascript as $key => &$script) {
$script['weight'] += $script['group'];
 $script['group'] = JS_DEFAULT;
 $script['every_page'] = TRUE;
if ($script['type'] === 'file') {
 $filename_min = preg_replace('/.js$/i', '.min.js', $script['data']);
if (file_exists($filename_min)) {
 $script['data'] = $filename_min;
 }
 }
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment