Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Is it possible to remove an already included javascript file? 
 
danpowered
Jr. Member
 
Total Posts:  9
Joined:  2008-05-01
 

I’d like to know, like my title says, if it is possible to remove a javascript file from the layout to replace it with a newer version, only in a specific view.

I developped a javascript library that would need prototype 2, but since theres already an older version included, theres conflict if i try to add the newer one with addJS (obviously).

Now, the specific view doesnt have anything else than what is needed for my library, so no other javascript would get broken.

I tried with removeJS, but id didnt do me any good.

Is it possible to do so?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
laurent
Member
 
Total Posts:  75
Joined:  2007-08-31
Paris, France
 

Yes, it’s possible to do so.

In fact, everything you need is in Mage_Page_Block_Html_Head.php.
addJs is a addItem shortcut for js but there is no removeItem shortcut for js.
So, make a new function removeJs or use removeItem like this:

<reference name="head">
        <
action method="removeItem"><type>js</type><name>prototype/prototype.js</name></action>
</
reference>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top