How to add/include js file into Magento theme

前端 未结 9 1017
予麋鹿
予麋鹿 2020-12-14 23:34

I am modifying a Magento theme. And want to add a js file into the theme /js folder. I have added the following code:

相关标签:
9条回答
  • 2020-12-15 00:22

    Best solution insert into local.xml file with reference name="head"

    <action method="addJs">
        <script>js/custom.js</script>
    </action>

    0 讨论(0)
  • 2020-12-15 00:24

    Please try this, i think this is the way to add our js/css files into the load.xml:

    <layout>
      <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <name>js/jquery-1.11.0.min.js</name>
            </action>
        </reference>
      </default>
    </layout>
    
    0 讨论(0)
  • 2020-12-15 00:28

    You can add your custom JS file in your theme's local.xml, located in: /app/design/frontend/{design package}/{theme}/layout/local.xml

     <?xml version="1.0"?>
     <layout version="0.1.0">
        <default>
           <reference name="head">
              <action method="addItem"><type>skin_js</type><name>js/script_name.js</name></action>
           </reference>
        </default>
     </layout>
    
    0 讨论(0)
提交回复
热议问题