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



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 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="-">
            <!-- RequireJs library enabled -->
            <argument name="file" xsi:type="string">requirejs/require.js</argument>
    <!-- Special block with necessary config is added on the page -->
    <block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config" after="requirejs"/>


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.