1

I tried the both ways,

Method 1:

<reference name="head">
   <action method="addItem">
       <type>skin_js</type><name>js/myJs.js</name>
   </action>
</reference>

The above gives default skin directory.

Method 2:

<reference name="head">
   <action method="addJs"><script>myJs.js</script></action>
</reference>

The above gives js directory.

But I Need the file located like the below to add via block and reference head.

src Path: http://www.example.com/wp/folder1/folder2/script.js

Here the http://www.example.com is store url.

How to implement this?

3 Answers 3

8

Try bellow way

Add custom CSS or JavaScript to CMS Pages With Custom JS Path

<reference name="head">
  <action method="addItem"><type>skin_js</type><name>js/your_foldername/your_js_name.js</name></action> 
  <action method="addItem"><type>skin_css</type><name>css/your_foldername/your_css_name.css</name><params/></action>
</reference>

Go admin side and add above code in CMS page in section (Layout Update XML) enter image description here

1

Login as Admin at your Magento store and once you are logged in to the Dashboard, navigate to the following...

System > Configuration > General > Design > Miscellaneous Scripts

Enter the following markup in the Miscellaneous Scripts text field box

<script type="text/javascript" src="wp/folder1/folder2/custom.js"></script>

Click Save Config to save your entry and that is all.

You may need to refresh your cache therefore if prompted navigate to System > Cache Management and refresh the appropriate caches.

2
  • this is not added Certain CMS Pages With Custom JS Path
    – Abdul
    Dec 18, 2015 at 12:41
  • Correct however the OP asked for the file to be located in the following way example.com/wp/folder1/folder2/script.js Using skin_Js or skin_css refers to Magento's theme folder.
    – sdots
    Dec 18, 2015 at 15:33
-1

To add a CSS file residing in the skin CSS folder

<reference name="head">
   <action method="addCss">
      <stylesheet>css/custom.css</stylesheet>
   </action>
</reference>

To add a Javascript file residing in the skin JS folder

<reference name="head">
   <action method="addItem">
      <type>skin_js</type>
      <name>js/custom.js</name>
      <params/>
   </action>
</reference>
2
  • Welcome to Magento SE and thanks for your contribution. Unfortunately your answer does not really help with the issue in the question, how to add a JS source outside the skin directory. Jun 14, 2017 at 10:11
  • so do i need to delete this answer ?
    – elaz
    Jun 14, 2017 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.