Add JS to All Pages

Categories: Magento - Tags:

Magento has various locations for its javascipt files and there are several ways to add them to your page.
In order to add js to all your pages use javascript inclusion instruction within <default> handle in your layout file.
Here are some examples:

The layout below will add js/mydir/myscript.js javascript to all pages.
<action method=”addJs”><script>mydir/myscript.js</script></action>

Similarly this will add js from skin/frontend/js_package/js_theme/js/myscript.js.
<action method=”addItem”><type>skin_js</type><name>js/jqzoom/jquery-1.3.1.min.js</name></action>

This will add js from lib/myjs.js to all pages as well.
<action method=”addItem”><type>js</type><name>lib/myjs.js</name><params/><if>lt IE 7</if></action>

Profile - Website


No comments yet.

Write a comment

You must be logged in to write a comment.

« »