Add CSS & Js to Magento Layout xml file

Below is the correct way to add css & js files from your theme’s skin and js folder .

  • Add css from theme’s skin in layout xml file-

<action method=”addCss”><stylesheet>css/styles.css</stylesheet></action>

OR

<action method=”addItem”><type>skin_css</type><name>css/menunav1.css</name>

<!– <params/><if>lt IE 8</if> : : (or) <params>media=”print”</params> (optional)–></action>

  • Add js from theme’s skin in layout xml file-

<action method=”addItem”><type>skin_js</type><name>js/js-image-slider.js</name></action>

  • Add js from main root js folder

<action method=”addJs”><script>jquery/jquery-1.8.3.min.js</script></action>

I have tested all above with version 1.7

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s