0

My theme is adding the following CSS below. How can I remove it? I know that with Drupal 6 you can do stylesheets[all][] = in the .info file but what about Drupal 7? Can hook_css_alter() be used on an external file?

<link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" media="all" />
1

You can use the following code to remove your external css

function hook_css_alter(&$css) {
  // Remove defaults.css file.
  unset($css['path of you external css']);
}
1

Yes, hook_css_alter can be used with external CSS.

1

Use function hook_css_alter you can unset css

function hook_css_alter(&$css) {
  // Remove defaults.css file.
  unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
}
0

You can use function hook_css_alter. This hook function will alter CSS files before they are output on the page.

//This hook function will unset css.
function hook_css_alter(&$css) {
    // Remove defaults.css file.
    unset($css['CSS FILE PATH']);
}

In additionally, you want to remove core css then follow below code:

function hook_css_alter(&$css) {
    $exclude = array(
        'misc/vertical-tabs.css' => FALSE
    );
    $css = array_diff_key($css, $exclude);
}

just add $exclude to your info to remove a CSS file. This is simple way to remove css file.

Let me know if there is any doubt/query from this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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