I'm using jquery tabs on my page but they loaded some default styles that I didn't want. Thus I removed them with the following code:

drupal_add_library('system', 'ui.tabs');

function mytheme_css_alter(&$css) {
   // List of disabled drupal default css files.
   $disabled_drupal_css = array(
      // Remove jquery.ui css files.
      //  'misc/ui/jquery.ui.tabs.css',

  // Remove drupal default css files.
     foreach ($css as $key => $item) {
         if (in_array($key, $disabled_drupal_css)) {
            // Remove css and its altered version that can be added by jquery_update.

This seems to do the trick, but I also noticed that my backend is not loading it's styles properly. I guess some of it uses the jquery.ui styles.

How can I load these only for the logged in user but not for

  • r u writing this in module or theme?
    – monymirza
    Mar 5, 2013 at 8:24
  • In theme, in template.php.
    – Johan Dahl
    Mar 5, 2013 at 8:25

2 Answers 2


I would use user_is_anonymous() function like this:

function yourtheme_css_alter(&$css) { 
  if(user_is_anonymous()) {
    $exclude = array(
      'misc/ui/jquery.ui.core.css' => FALSE,
      'misc/ui/jquery.ui.theme.css' => FALSE,
    $css = array_diff_key($css, $exclude);

i guess you use the your theme also as admin theme. just use seven as admin theme, and this hook will not be considered.

otherwise you have to check in the hook if your on an admin page, like

if (path_is_admin(current_path())) {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.