Max
Max

Reputation: 674

Remove all js and css from theme [Drupal 7]

In html.tpl.php I have 2 variables: $styles and $scripts

But they not reset by template function:

function MYTHEME_preprocess_html(&$vars) {
   $vars['styles'] = null;
   $vars['scripts'] = null;
}

How can I reset this variables?

Upvotes: 2

Views: 1881

Answers (3)

Buntu Linux
Buntu Linux

Reputation: 502

This game a jQuery not found error

drupal_static_reset('drupal_add_js');

I managed to remove all js by:

function TEMPLATE_js_alter(&$js){
    unset($js['misc/jquery.once.js']);
    unset($js['misc/jquery.js']);
    unset($js['misc/drupal.js']);
    unset($js['settings']);
}

Upvotes: 1

Mike Vranckx
Mike Vranckx

Reputation: 5577

If you want to remove all data set to those 2 variables, you could use the *template_process_html()* hook which is called after the *template_preprocess_html()*.

function MYTHEME_process_html(&$vars)
{
    $vars['styles'] = null;
    $vars['scripts'] = null;
}

Upvotes: 0

Max
Max

Reputation: 674

Solution:

function MYTHEME_preprocess_html(&$vars) {
    # Reset CSS and JS
    drupal_static_reset('drupal_add_css');
    drupal_static_reset('drupal_add_js');
}

Upvotes: 0

Related Questions