Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have to do it the other way around. Unsetting files of other contrib modules explicitly couples your module to every other module that outputs js to the header. You won't be able to maintain that for too long before it breaks. What happens when more js files get added by contrib modules?</p> <p>You're best to create a mask of paths you want to output and unset everything except those.</p> <p>Drupal 7 has some hooks that will let you do that but I can't remember them. If you're on D6 you're kinda stuck.</p> <p>I did write a <strong>dirty</strong> workaround for <strong>Drupal 6</strong> for this same problem with css files. Here is the whole module (it was only 3 functions). I'm sure you can adapt it to js files too.</p> <p><strong>Create your mask (expose it to the variables table)</strong></p> <pre><code>function destroy_mask_styles() { return variable_get('destroy_mask_styles', array('all/modules/mymodule', 'themes/mytheme')); } </code></pre> <p><strong>Then here comes the dodgey part. This function looks for the paths of the css files in the header and unsets them if they don't match.</strong></p> <pre><code>function destroy_styles($var_styles) { //this is a bit dodgey. But it's probably the easiest way to implement $masks = destroy_mask_styles(); $styles = array(); foreach(explode("\n", $var_styles) as $style) { foreach($masks as $mask) { if(strpos($style, $mask) &gt; 0) { $styles[] = $style; } } } return implode("\n", $styles); } </code></pre> <p><strong>Then in preprocess_page,</strong> (this might be considered where the dodgyness happens)</p> <pre><code>function destroy_preprocess_page(&amp;$variables) { //destroy some css and scripts we don't want $styles = destroy_styles($variables['styles']); $variables['styles'] = empty($styles) ? $variables['styles'] : $styles; } </code></pre> <p>If you want to include everything from one module (for example), just alter the paths that get matched to include the path to the module's root folder. Don't worry about file names.</p> <p>Remember that this is not the ideal way to do this. There might be a better way in D6 but there are no hooks here so probably not.</p> <p>Good luck!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload