Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where/how to add custom js magento

I made a magento module, and I need to add some custom javascript.

I put the following in my layout file (and it's working, with my custom js places in /js/):

<default>
    <reference name="head">
        <action method="addJs"><script>http://code.jquery.com/jquery.min.js</script></action>
        <action method="addJs"><script>my_custom_js.js</script></action>
    </reference>
</default>

My question is - where is the best place for these files, in /js/jquery/ or in /skin/frontend/default/default/js? If I put it in default/default, how do I reference it from the XML?

like image 734
Vlad Preda Avatar asked Jan 23 '13 10:01

Vlad Preda


1 Answers

If it is required for your module (critical functionality):

/js/[namespace]/[module]/

If it is required for a theme (UI enhancement):

/skin/frontend/[group]/[theme]/js/
like image 96
Fabian Schmengler Avatar answered Oct 11 '22 04:10

Fabian Schmengler