Hi,
How can I disable stylesheets that are provided by Drupal core? I mean especially defaults.css, system.css and system-menus.css. Those are so messed up that I would prefer to rewrite and split them to my custom stylesheets.

In Drupal 6 I could prevent Drupal from loading core stylesheet by defining them in info file. Sample:

stylesheets[all][] = defaults.css
stylesheets[all][] = system.css
stylesheets[all][] = system-menus.css

Of course this made no sense (enable stylesheets to disable them?!). But it worked.

Now we have Drupal 7 which changes old behavior: defining core stylesheets in info file will not load them, BUT it will generate markup which loads those files from theme directory, no matter whether they exist or not, which in my case results in broken

links. Is there some magic code that I could put in my template.php file to disable unwanted CSS files?

Comments

drawqc’s picture

How is this related to my question? I have already read this page several times.

AgaPe’s picture

under this link it says that these styles are not loaded in Drupal 7 unless you add them.
but i have a style build on the bartik theme and its not added in the theme.info nor in template.php but these system css are loaded, and don't know yet how to remove them.

AgaPe’s picture

found a solution, it can be a theme or a module hook

function hook_css_alter(&$css) { 
    unset($css[drupal_get_path('module','system').'/system.theme.css']); 
}
squarecandy’s picture

thanks - that works great for completely removing system css files!

RgnYLDZ’s picture

How does this work? I mean I want to remove the css files to load a cleaner css markup.

With this method, are the core css files loaded and then removed? Or are they stopped before loading.

Jaypan’s picture

It depends on how you define 'loaded'. But by removing it with hook_css_alter() the CSS file will never be sent to the browser in the response from the server.

RgnYLDZ’s picture

Thanks, I'll use this method in my next project. It will not make a huge difference I think. But why the load and/or overwrite the same element a few times.

For example sometimes for a single element the font-size or some other simple css is overwritten a couple times. Really unnecessary.