Loading JavaScript in Magento Selected Pages

Load JavaScript in Magento on some pages.

By using $this->getRequest()->getControllerName() on any of your files in template folder you would get the name of the current controller. If you are on let’s say http://somesite.domain/shop/index.php/checkout/onepage/ page, your controller name is onepage. By using the above mentioned code your result would be string “onepage“. So all you need to do is to write a simple IF statement like

<?php if($this->getRequest()->getControllerName() !== ‘onepage’) { ?>
         // your javascript statements goes here
<?php } ?>

I hope you guys find this one helpful.