How to remove JS from a page during preprocess D7 I'm trying to remove few JS files from one page, which will be called in an Iframe (so no TEMPLATE_js_alter possible because of the if condition).

This code below unset the JS but they are still loaded on the page. It's like I can't save the new list of JS.

Any ideas ?

 function theme_preprocess_page(&amp;$variables) {
        $scripts = drupal_add_js();
        dsm($scripts);

        if(arg(0) == "account" &amp;&amp; arg(1) == "reset"){
            foreach ($scripts as $key =&gt; $value) {
                $uri = strrpos($key, 'sites/all');
                if($uri !== FALSE){
                    unset($scripts[$key]);
                }
            }
            $variables['scripts'] = $scripts;
        }
    }
You can try hook_js_alter and remove it from there:

module_hook_js_alter(&amp;$data) {
  dpm($data);
  unset($data['script']);
  dpm($data);
}