Magento remove css or js from specific view

zsitro picture zsitro · Jan 30, 2012 · Viewed 35.2k times · Source

Hi i added this to catalog.xml layout definition:

<reference name="head">
    <action method="addCss"><stylesheet>css/local.css</stylesheet></action>
</reference>

and this to inside the same file:

<action method="removeItem"><type>css</type><name>css/local.css</name></action>

But it doesn't remove the css from that view. It is possible, that its not the right markup to achieve this. But have no idea. Anyone can help out?

Answer

Shadoweb picture Shadoweb · Oct 29, 2013

Here is how to remove all the different CSS and JS in skin or js folder

<reference name="head">
    <!-- For a JS in the js folder -->
    <action method="removeItem"><type>js</type><name>functions.js</name></action>
    <!-- For a JS in the skin folder -->
    <action method="removeItem"><type>skin_js</type><name>functions.js</name></action>
    <!-- For CSS in the skin folder -->
    <action method="removeItem"><type>skin_css</type><name>css/local.css</name></action>
    <!-- For CSS in the js folder -->
    <action method="removeItem"><type>js_css</type><name>local.css</name></action>
</reference>