0

All js script are loaded in footer in magento 1.9. I want them in head. Can Anyone let how to do this ?

0

Who told you that the JS files are loaded in footer ? the JS files are declared and loaded from and in head.

Here is the native way how to include a JS file:

<?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>
  • In default its in head. but there is an script or something that pull the js in footer – pankaj kumar Mar 9 '18 at 13:14
  • So if I decide to remove the footer from my website, there will be no JS that will be loaded ? – PЯINCƏ Mar 9 '18 at 13:17
0

To add js in the head you can edit layout xml files where you want your scripts in the head.

Example in \app\design\frontend[your-theme]\default\layout\page.xml:

<layout version="0.1.0">
    <default translate="label" module="page">
        <block type="page/html" name="root" output="toHtml" template="page/2columns-left.phtml">
            <block type="page/html_head" name="head" as="head">
                <action method="addJs"><script>script.js</script></action>
                <action method="addItem"><type>js</type><name>script2.js</name></action>
                <action method="addItem"><type>skin_js</type><name>script3.js</name></action>
            </block>
        </block>
    </default>
</layout>

This are just some examples. Hope this helps.

Edit: I think you have a modified version of Magento 1.9 because in the default version all js are in the head.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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