Wednesday, October 3, 2012

Magento : Add/Remove js file

Use following code
Add js through layout file
<reference name="head" as="head">
<action method="addJs"><script>folder_name/file_name.js</script></action>
</reference>
and through php code
echo $this->getLayout()->getBlock('head')->addJs('folder_name/file_name.js');

Remove js through layout file
<reference name="head" as="head">
<action method="removeItem"><type>js</type><name>folder_name/file_name.js</name</action>
</reference>
and though php code
$this->getLayout->getBlock('head')->removeItem('js','folder_name/file_name.js');

No comments:

Post a Comment