If you want to override the Magento JS core and replace it by your custom Javascript.
Step 1:
Create a RequireJS configuration file requirejs-config.js
var config = {
"map": {
"*": {
"<default_component>": "<custom_component>"
}
}
};
- Where the following notation is used:
<default_component>
: the name of the default component you replace
<custom_component>
: the name of the custom component
Example, if you want to use custom navigation-menu.js script instead
of the default menu widgets, your requirejs-config.js should contain
the following:
var config = {
"map": {
"*": {
"menu": "/js/navigation-menu",
"mage/backend/menu": "js/navigation-menu",
}
}
};
Step 2:
Place your requirejs-config.js file in one of the following directories (it depends on the location of your custom script):
- Your theme files:
- Your module view files: /view/frontend
The 2 steps I mention above is the shortest process for you to Override Magento JS Core in Magento 2. With this guide, you can manage the Magento JS Core in Magento 2 easily. Every store has a Magento JS Core in Magento 2 with many attributes.
I hope this will help