1

I'd like to know how to add external jQuery files to magento (on every page). And what is the best practice to do so?

Thanks

2 Answers 2

3

Just do this.
on the frontend (a default theme) do the modification for " app / design / frontend / default / default / layout / page.xml and then add this :

<action method="addJs"><script>jquery/jquery.min.js</script></action> to block with name “head” . 

And on the backend (a default theme) do the modification for " modify app / design / adminhtml / default / default / layout / main.xml. :

Thats how javascript files will be included in every page header.
And here is a link to which you can refer and learn more.
http://www.fontis.com.au/blog/magento/using-jquery-magento " to learn more.

here is how you gotta write the " noConflict " .

<default>
<reference name="head">
    <block type="core/text" name="google.cdn.jquery">
        <action method="setText">
            <text><![CDATA[<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>]]>
            </text>
        </action>
    </block>
</reference>

Good luck

Sign up to request clarification or add additional context in comments.

5 Comments

okay so i have a theme that already uses jQuery files. So i think that i can safely assume that jQuery.noConflict() method would have been already applied, right? So will just adding jQuerry files to the page.xml will do the trick?
You gotta write the " noConflict " too . I'd just add it to my codes.
I suggest you to read this too . fontis.com.au/blog/magento/using-jquery-magento
1) Create & use local.xml for layout modifications; do not modify page.xml. 2) Do not hardcode the protocol or you will get insecure content warnings on checkout.
@benmarks okay benmarks thanks. But how will i include the new page.xml file in my magento pages? and where should i keep it?(which directory)
0

You can put it in Page.xml. You can find it in the layout folder of your template. In order to avoid conflicts with other libraries, you should call jQuery.noConflict()

Comments

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.