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? Commented Apr 12, 2017 at 13:32
  • You can write this code in local.xml in your theme folder Commented 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? Commented 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.