Magento : Add Or Remove Javascript on Head Section file using a Block File

0
29
views
Advertisement

Hi, All

Following code will help you add or remove javascript file on Head Section using a block file

put following code in your module block file.

protected function _prepareLayout()
{
    parent::_prepareLayout();
  
    //Code for remove Javascript
    $this->getLayout()->getBlock(‘head’)->removeItem(‘js’, ‘prototype/prototype.js’);
  
    //Code for Add Javascript
    $this->getLayout()->getBlock(‘head’)->addJs(‘prototype/prototypeadmin.js’);

}

Ok, we are done !!! Please leave your comments here. 🙂

I hope this helps someone 🙂

Thanx,
Mayank Zalavadia  🙂