I'm using Drupal 6.x and I'm trying to remove some of the JavaScript (JS) files that get generated inside the source if and only if the current page is of a particular content type I designate (for example, if some of the modules I use generate a bazillion JavaScript references inside the markup, well, it would be nice to be able to remove some of those if they're not needed.) Having this capability would allow me to remove unnecessary overhead.

So in trying to accomplish this, I've come up with the following code:

PHP Code:
function <THEME NAME>_preprocess_page(&$variables){
arg(2) == '<CONTENT TYPE>' && arg(1) == 'edit' || arg(1) == 'add'){
$scripts drupal_add_js();                
$css drupal_add_css(); 
$path base_path().'sites/all/libraries/syntaxhighlighter_3.0.83/scripts/shCore.js';                
$scripts['module'][$path]);//At this point, this is NULL--so it works here.
$variables['scripts'] = drupal_get_js('header'$scripts);//I  think this is where I'm having problems. The output should not have  that shCore.js file in it, but it does when you view the source...

        if (isset(
$variables['node']) && $variables['node']->type != "" && arg(2) != 'edit' && $variables['template_files'][2] != 'page-node-delete') {                
$variables['template_files'][] = "page-" $variables['node']->type;        

In the above code, I'm trying to remove "shCore.js" from the end-user's markup stack (this is just an example I was trying to test with; this particular file is output by the "syntaxhighlighting" module). This preprocessing function looks to see what content type the current page is, determines if it's an "add" or "edit" page, and then based on this, attempts to unset whatever is found within $path. After that, I'm trying to re-insert what's in the $scripts array back into $variables['scripts'] to be output to the end-user.

Unfortunately, that JS file still gets output... I'm just not sure what I'm doing wrong. I think it might have to do with the fact that I'm trying to remove / unset a library-based JS file, but this is pure speculation at this point.

Any insight would be appreciated. Long story, short: I'm just trying to remove unnecessary JS files form the markup stack if and only if they're not needed.