Skip to content

Instantly share code, notes, and snippets.

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