cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable Require.js in Magento 2

How to enable Require.js in Magento 2

Hi,

 

Not sure If I'm misunderstanding or what, but do you have to enable Require.js in order for it to load your jQuery library? I've tried as this article states http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/js-resources.html by including this within the Magento_Theme/layout/default.xml page:

 

<referenceBlock name="head">
    <block class="Magento\Theme\Block\Html\Head\Script" name="requirejs" before="-">
        <arguments>
            <!-- RequireJs library enabled -->
            <argument name="file" xsi:type="string">requirejs/require.js</argument>
        </arguments>
    </block>
    <!-- Special block with necessary config is added on the page -->
    <block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config" after="requirejs"/>
</referenceBlock>

 

But I'm not sure if this is the correct way to enable require.js or if I'm misunderstanding.

 

Also, when I inserted the above code I found a error in the Chrome console:

Failed to load resource: the server responded with a status of 404 (Not Found)

require.js:141 Uncaught Error: Script error for: jquery/jquery-storageapi(…)

 

I'm honestly not even 100% sure that I need to enable require.js, but it seems like I do. 

 

Thanks!