mothership is all about removing... but I have to say I do not like clicking around to remove my CSS.

With hook_css_alter we can remove CSS and with some magic with can use directly an css-exclude key in .info.

somthing like

css-excclude[] = modules/system/system.css

What will be very cool is if we can use * in path and even in name (so you can remove in one line all the somthings.theme.css.

css-excclude[] = */system.css
css-excclude[] = *.theme.css

The theme twitter_bootstrap (and others) already implement something similar.

 function twitter_bootstrap_css_alter(&$css) {
//global $theme_key;
//$theme_path = drupal_get_path('theme', $theme_key);

$excludes = _twitter_bootstrap_alter(twitter_bootstrap_theme_get_info('exclude'), 'css');
$css = array_diff_key($css, $excludes);
}

function twitter_bootstrap_js_alter(&$js) {
$excludes = _twitter_bootstrap_alter(twitter_bootstrap_theme_get_info('exclude'), 'js');
$js = array_diff_key($js, $excludes);
 }

 function _twitter_bootstrap_alter($files, $type) {
 $output = array();

 foreach($files as $key => $value) {
 if(isset($files[$key][$type])) {
 foreach($files[$key][$type] as $file => $name) {
 $output[$name] = FALSE;
 }
 }
 }
 return $output;
 }

Comments

betovarg’s picture

Dont know about JS but, isnt that why FOAD is in the .info file?

gagarine’s picture

FOAD??

betovarg’s picture

Yeah, its a known technique:
http://drupal.org/node/1536790

gagarine’s picture

ah ok.. I know about this.. didn't know we made a cool name for this not intuitive and terrible design.

This use a file_exist to check than your files doesn't exist! And for the themer side, by looking at the .info he can't know if you add, remove or overwrite a CSS...

It also doesn't support wildcard.

realityloop’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

If you use the magic module you can add excludes for CSS and JS in the info file, in fact 3.x has some default magic settings in place already