Magento 2 Tips : Conditionally Loading Javascript and css in layout xml

Posted Over 9 years ago. Visible to the public.

First create your conditions in the system.xml..

Second add your css and js in your local xml.

<reference name="head">
    <action method="addCss" ifconfig="my_config_section/advanced/load_css"><stylesheet>css/my_module/my_module.css</stylesheet></action>
    <action method="addItem" ifconfig="my_config_section/advanced/load_js"><type>skin_js</type><name>js/my_module/my_module.js</name></action>
</reference>
vasan
Last edit
Almost 3 years ago
vasan
Keywords
Magento, CSS, JS
Posted by vasan to vasan's deck (2014-12-11 05:55)