2

I need to load some JS libraries the last of all. I used to achieve this using data-group param, like this:

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <!-- <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/jquery-1.7.2.min.js</name></action> -->
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/lazy-image-loader.js</name><params><![CDATA[data-group="js002"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/common.js</name><params><![CDATA[data-group="js002"]]></params></action>
        </reference>
    </default>
    <catalog_category_default translate="label">
        <reference name="head">
            <!-- <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/jquery-1.7.2.min.js</name></action> -->
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/lazy-image-loader.js</name><params><![CDATA[data-group="js002"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/common.js</name><params><![CDATA[data-group="js002"]]></params></action>
        </reference>
    </catalog_category_default>
    <catalog_category_layered translate="label">
        <reference name="head">
            <!-- <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/jquery-1.7.2.min.js</name></action> -->
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/lazy-image-loader.js</name><params><![CDATA[data-group="js002"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/common.js</name><params><![CDATA[data-group="js002"]]></params></action>
        </reference>
    </catalog_category_layered>
    <catalogsearch_result_index translate="label">
        <reference name="head">
            <!-- <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/jquery-1.7.2.min.js</name></action> -->
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/lazy-image-loader.js</name><params><![CDATA[data-group="js002"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/mgt_lazy_image_loader/common.js</name><params><![CDATA[data-group="js002"]]></params></action>
        </reference>
    </catalogsearch_result_index>
</layout>

and it was working fine, js files were loaded at the end.

Now i need to load some new libraries after these one, so i created a new data-group:

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
    <catalog_category_layered> <!-- find all category pages with layered navigation -->
        <update handle="mana_ajax" />
        <reference name="head">
            <action method="addJs"><script>jquery/history.adapter.jquery.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addJs"><script>jquery/history.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/manapro_filterajax.js</name><params><![CDATA[data-group="js003"]]></params></action>
        </reference>
        <reference name="top.menu">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="content">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="left">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="right">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="breadcrumbs">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="category.products">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="mana.catalog.leftnav">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="m_ajax_update">
            <action method="setRenderedButNotSentBlocks"><blocks>m_ajax_update,head</blocks></action>
            <action method="setUpdatedBlocksIfPageChanged"><updated_blocks>content,left,right,breadcrumbs,top.menu</updated_blocks></action>
            <action method="setUpdatedBlocksIfParameterChanged"><updated_blocks>category.products,mana.catalog.leftnav,mana.catalog.rightnav</updated_blocks></action>
            <action method="setInterceptedLinkContainers"><css_selector>.mb-mana-catalog-leftnav,.mb-mana-catalog-rightnav,.block-layered-nav.m-topmenu,.block-layered-nav.m-top,.toolbar</css_selector></action>
            <action method="setExceptions"><regular_expr>[\?&amp;]options=|checkout/cart/add|catalog/product_compare/add|wishlist/index/add</regular_expr></action>
        </reference>
    </catalog_category_layered>
    <catalogsearch_result_index> <!-- find all catalog search result page -->
        <update handle="mana_ajax" />
        <reference name="head">
            <action method="addJs"><script>jquery/history.adapter.jquery.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addJs"><script>jquery/history.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/manapro_filterajax.js</name><params><![CDATA[data-group="js003"]]></params></action>
        </reference>
        <reference name="top.menu">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="content">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="left">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="right">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="breadcrumbs">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="search.result">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="mana.catalogsearch.leftnav">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="mana.catalogsearch.rightnav">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="m_ajax_update">
            <action method="setRenderedButNotSentBlocks"><blocks>m_ajax_update,head</blocks></action>
            <action method="setUpdatedBlocksIfPageChanged"><updated_blocks>content,left,right,breadcrumbs,top.menu</updated_blocks></action>
            <action method="setUpdatedBlocksIfParameterChanged"><updated_blocks>search.result,mana.catalogsearch.leftnav,mana.catalogsearch.rightnav</updated_blocks></action>
            <action method="setInterceptedLinkContainers"><css_selector>.mb-mana-catalogsearch-leftnav,.mb-mana-catalogsearch-rightnav,.block-layered-nav.m-topmenu,.block-layered-nav.m-top,.toolbar</css_selector></action>
            <action method="setExceptions"><regular_expr>[\?&amp;]options=|checkout/cart/add|catalog/product_compare/add|wishlist/index/add</regular_expr></action>
        </reference>
    </catalogsearch_result_index>
    <cms_page_layered>
        <update handle="mana_ajax" />
        <reference name="head">
            <action method="addJs"><script>jquery/history.adapter.jquery.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addJs"><script>jquery/history.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/manapro_filterajax.js</name><params><![CDATA[data-group="js003"]]></params></action>
        </reference>
        <reference name="top.menu">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="content">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="left">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="right">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="breadcrumbs">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="cms.products">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="mana.catalog.leftnav">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="mana.catalog.rightnav">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="m_ajax_update">
            <action method="setRenderedButNotSentBlocks"><blocks>m_ajax_update,head</blocks></action>
            <action method="setUpdatedBlocksIfPageChanged"><updated_blocks>content,left,right,breadcrumbs,top.menu</updated_blocks></action>
            <action method="setUpdatedBlocksIfParameterChanged"><updated_blocks>content,mana.catalog.leftnav,mana.catalog.rightnav</updated_blocks></action>
            <action method="setInterceptedLinkContainers"><css_selector>.mb-mana-catalog-leftnav,.mb-mana-catalog-rightnav,.block-layered-nav.m-topmenu,.block-layered-nav.m-top,.toolbar</css_selector></action>
            <action method="setExceptions"><regular_expr>[\?&amp;]options=|checkout/cart/add|catalog/product_compare/add|wishlist/index/add</regular_expr></action>
        </reference>
    </cms_page_layered>
    <mana_optionpage_view>
        <update handle="mana_ajax" />
        <reference name="head">
            <action method="addJs"><script>jquery/history.adapter.jquery.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addJs"><script>jquery/history.js</script><params><![CDATA[data-group="js003"]]></params></action>
            <action method="addItem"><type>skin_js</type><name>js/manapro_filterajax.js</name><params/><params><![CDATA[data-group="js003"]]></params></action>
        </reference>
        <reference name="top.menu">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="content">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="left">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="right">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="breadcrumbs">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="option_view">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="mana.catalog.leftnav">
            <action method="setMClientSideBlock"><params><type>Mana/Core/Block</type></params></action>
        </reference>
        <reference name="m_ajax_update">
            <action method="setRenderedButNotSentBlocks"><blocks>m_ajax_update,head</blocks></action>
            <action method="setUpdatedBlocksIfPageChanged"><updated_blocks>content,left,right,breadcrumbs,top.menu</updated_blocks></action>
            <action method="setUpdatedBlocksIfParameterChanged"><updated_blocks>option_view,mana.catalog.leftnav,mana.catalog.rightnav</updated_blocks></action>
            <action method="setInterceptedLinkContainers"><css_selector>.mb-mana-catalog-leftnav,.mb-mana-catalog-rightnav,.block-layered-nav.m-topmenu,.block-layered-nav.m-top,.toolbar</css_selector></action>
            <action method="setExceptions"><regular_expr>[\?&amp;]options=|checkout/cart/add|catalog/product_compare/add|wishlist/index/add</regular_expr></action>
        </reference>
    </mana_optionpage_view>
</layout>

However, scripts tagged with js002 still loads after js003 ones. How can i can change load order? Any help will be appreciated.

Thanks in advance, Antonio.

Your Answer

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

Browse other questions tagged or ask your own question.