How to Override Magento JS core in Magento 2

Sometimes you want to modify Magento JS core. But you can’t modify directly in Magento source code .so you should over-ride Magento JS. The following steps will show you how to over-ride Magento Js core in Magento 2

Step 1:

Create Requires configuration file requires.config.js

var config = {

  "map": {

    "*": {

      "<default_component>": "<custom_component>"

    }

  }

};

The following notations are:

  1. Default component
  2. Custom component

For example: if you want to use custom component instead of default component your requires.config.js should contain the following steps:

var config = {

  "map": {

    "*": {

      "menu": "/js/navigation-menu",

      "mage/backend/menu": "js/navigation-menu",

    }

  }

};

Step 2:

Set your needs.config.js in one in all the subsequent directories:

Theme file:<Theme_dir>

Module file:  <module_dir>/view/frontend</code>

The above mentioned two steps are the shortest process for you to manage how to override MagentoJS core in Magento 2 easily. Each store in Magento has several elements.

Last Update: January 21, 2019  

February 5, 2018   792   Nandini R    Java Script    
Total 3 Votes:
1

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
Twitter
INSTAGRAM
LinkedIn