Skip to main content
edited tags
Link
zhartaunik
  • 3.8k
  • 4
  • 24
  • 54
added 8 characters in body; edited tags
Source Link
Marius
  • 198.5k
  • 55
  • 424
  • 833

I add a custom JavaScript file with the following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="VendorNamespace_Module::someJs.js"/>
    </head>
</page>

My problem is that this js file requires jQueryjQuery, but it is loaded before the jQueryjQuery JavaScript file (when I look at the head section of my html, jQuery.jsjQuery.js comes after someJs.jssomeJs.js). How can I change this order so that my file is loaded afterwards?

I add a custom JavaScript file with the following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="VendorNamespace_Module::someJs.js"/>
    </head>
</page>

My problem is that this js file requires jQuery, but it is loaded before the jQuery JavaScript file (when I look at the head section of my html, jQuery.js comes after someJs.js). How can I change this order so that my file is loaded afterwards?

I add a custom JavaScript file with the following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="VendorNamespace_Module::someJs.js"/>
    </head>
</page>

My problem is that this js file requires jQuery, but it is loaded before the jQuery JavaScript file (when I look at the head section of my html, jQuery.js comes after someJs.js). How can I change this order so that my file is loaded afterwards?

Source Link
bpoiss
  • 773
  • 2
  • 8
  • 24

Change order of JavaScript files in head

I add a custom JavaScript file with the following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="VendorNamespace_Module::someJs.js"/>
    </head>
</page>

My problem is that this js file requires jQuery, but it is loaded before the jQuery JavaScript file (when I look at the head section of my html, jQuery.js comes after someJs.js). How can I change this order so that my file is loaded afterwards?