How can I remove javascript from everywhere but the front page? I tried using this in template.php

function MYTHEME_js_alter(&amp;$javascript) {
  if ($!is_front) {
    unset($javascript['path/to/script.js']);
  }
}


but it doesn't work. Performance wise, would it be as good to have the javascript that's on every page in theme.info, then use drupal_add_js on the front page instead?
You need to update. Below are the update :

if (!drupal_is_front_page()) {
      unset($javascript['path/to/script.js']);
    }


function drupal_is_front_page

Reference Link : Click Here