How to override Magento JS core in Magento 2? – Magento 2.3

Sometimes you want to modify the 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 override Magento Js core in Magento 2.

Get build your Magento store with no-time, consult today!!!

Override 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 a custom component instead of a default component like 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 Magento JS core in Magento 2 easily. Every store in Magento has several elements.

How to override magento JS core in magento 2? - Magento 2.3

Last Update: February 12, 2021  

February 5, 2018   3612   Nandini Ramachandran    Java Script, Magento, Magento 2 Tutorial    
Total 5 Votes:
3

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