1

I've come here after looking for how to selectively add a CSS or JS to a given node based on its view mode and content type. That question is answered pretty straightforward here (http://stackoverflow.com/questions/8295498/how-to-add-css-and-js-files-on-node-pages-independent-of-the-theme).

Now I'd love to clear everything: I'm looking for a way to show my desired CSS and JS but only that, with no other JS and CSS. I'm trying to integrate Impress.js (And I don't like the available solutions) and it seems to be conflicting with Jquery, as both scripts are properly loaded but both latest Firefox and Chromium browsers throw the "old browser" message.

Any ideas on how to unset every single CSS and JS so that the CSS and JS I want to use are the only ones really active?

Thanks!

I've tried the following, to no success:

$mycss = $vars['styles'];

unset($micss[drupal_get_path('module','system') .'/system.base.css']);

...

unset($micss[drupal_get_path('module','toolbar') .'/toolbar.css']);

$vars['styles'] = $mycss;

(I added a lot of different css i want to get rid of, but this explains the idea). It didn't work, though :)

Edit. I'm sorry for the bad markup, I'm looking for a way to clean/mark code.

jantimon
  • 36,840
  • 23
  • 122
  • 185
versvs
  • 643
  • 2
  • 12
  • 30
  • If it is done programatically, added to the code I have now it would make a general purpose module, it would be nice. For a fast solution, anything is OK. – versvs Apr 13 '12 at 10:29

1 Answers1

2

In your custom module use:

function yourmodule_js_alter(&$js) {
    unset(
        $js['misc/drupal.js'],
        $js['misc/jquery.js']
        .... etc.
    );
}

You say you want to only do this for certain content types, so try:

if(arg(0) == 'node') {
    $node = node_load(arg(1));
    if($node->type == 'your_content_type') {
        unset(
            $js['misc/drupal.js'],
            $js['misc/jquery.js']
            .... etc.
        );
    }
}

Jonny

jonshot
  • 735
  • 6
  • 12
  • Though my problem persists (it seem that this is not related to jquery vs impress), My question is properly answered here... so kudos. In retrospect, it was pretty what to do... Just knowing the correct hook to look for :) Thanks! – versvs Apr 13 '12 at 15:15