Jake's blog posts Nic's blog posts Jamey's blog posts David's blog posts

jake

Disabling all Drupal CSS files

by jake ~ December 15th, 2008. Filed under: Drupal.

We needed to disable all of Drupal’s CSS files from our theme. Here’s how we did it:

function THEMENAME_preprocess(&$variables) {

  // Get rid of all of Drupal's CSS files
  $css = drupal_add_css();
  foreach ($css['all']['module'] as $file => $status) {
    if (!strstr($file, 'modules/MYMODULE')) {
      unset($css['all']['module'][$file]);
    }
  }
  $variables['styles'] = drupal_get_css($css);

We also wanted (no *real* need) to use screen.css rather than style.css, so we edited THEMENAME.info to have this:

stylesheets[all][] = reset.css
stylesheets[all][] = screen.css

… and we removed the line for style.css from it.

Finally, as the superuser we went to /admin/build/modules (or /themes, can’t remember now) to refresh the theme cache. We also had to tick to enable the theme at /admin/build/themes as although we’d been using the theme for ages quite fine, it wasn’t actually ticked before.

And hey presto, it worked. Should probably add that it took waaaay too long to do though, so though we’d add this snipped for others to read.

2 Responses to Disabling all Drupal CSS files

  1. btopro

    Any way this could be a module? I can definitely see the advantage of disabling all style properties for the admin to get through things faster. Might be cool if there was a way to strip out all javascript / CSS that wasn’t system critical for a bare-bones admin view. A lot of times I make a theme called “blank” and just load stuff up w/o styling though this definitely seems like it would be faster.

  2. Adam Shore

    Try this one – http://drupal.org/project/stylestripper – it’s super sweet and very underused!

    Cheers,

    Adam

Leave a Reply