0

How can I include a JQuery script to every CMS page within a theme.

Placing the .js file in:

app/design/frontend/<company>/<theme>/web/js/file.js

and using script tags(below) in the CMS page doesnt work.

<script src="js/file.js">

1 Answer 1

2

Put this code in the local.xml in your theme folder:

<cms_page>
    <reference name="head">
        <action method="addJs"><script>path/to/my/file.js</script></action>
    </reference>
</cms_page>
3
  • Where am I suppose to place this xml file? and does the file have a fixed filename I need to use? Apr 12, 2017 at 13:32
  • You can write this code in local.xml in your theme folder Apr 12, 2017 at 13:35
  • There was a no local.xml in my theme folder so I made one in <theme>/etc/local.xml, but its not included. Is there a command I should be running before it takes effect? Apr 12, 2017 at 14:04

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.