In our custom module, we have pages similar to the order page. We need some changes in the scripts.js file only in those custom module pages. Following is the core file we are using is

module-sales/view/adminhtml/web/order/create/scripts.js .

In order to override we added requirejs-config.js in the following location


with the following content

var config = {
    map: {
        '*': {
            'Magento_Sales/order/create/scripts': 'Namespace_Module/js/scripts',

We copied the scripts.js file in the custom file scripts.js in the following location


The custom module pages are working as we expected. But the modifications are affecting not only in custom module pages but also in the Magento pages also.

Please, can anyone help?

  • so you want to do for both or only your page? – Sunil Patel Nov 29 '17 at 6:58
  • @SunilPatel I want to do it for only my page. – coderunner Nov 29 '17 at 7:04
  • 1
    you can create js and initialize your js for only your page so it will work, don't override it – Sunil Patel Nov 29 '17 at 7:29
  • 1
    @SunilPatel Can you please guide on how to do it? – coderunner Nov 29 '17 at 7:31
  • can i know which type of modification you did? because if you intilize other js then you need to call that js from phtml file and i checked it is contain lot of files – Sunil Patel Nov 29 '17 at 7:39

When you are overriding script.js using requirejs-config.js it's not only works for your custom module but whenever that core script.js will be called your custom js will be called instead od core script.js.

So if you want to use that script.js code into your custom module only, You have to create your own custom js same as script.js because override means you replaced js code with your own js for whole Magento.

'Magento_Sales/order/create/scripts': 'Namespace_Module/js/scripts', means you are overriding core js file so when Magento tries to call Magento_Sales/order/create/scripts, your 'Namespace_Module/js/scripts will be called.

If you want to create your own js file you have to give custom reference name to your js file in requirejs-config.js like: 'myscript': 'Namespace_Module/js/scripts',

  • That is what I have done. I have created my own script.js. However, the core file is also taking my JS file. – coderunner Nov 29 '17 at 7:05
  • you have not created your own js, You have overridden core js – Ronak Chauhan Nov 29 '17 at 7:06
  • 1
    'Magento_Sales/order/create/scripts': 'Namespace_Module/js/scripts', this will override js not create new js – Ronak Chauhan Nov 29 '17 at 7:07
  • 1
    to create your own js you have to give your custom reference to your js like: 'myscript': 'Namespace_Module/js/scripts', – Ronak Chauhan Nov 29 '17 at 7:07
  • 1
    copy code of the core file into your custom js file that is not the proper way but have to bind all things which used in core js and use it properly. – Ronak Chauhan Nov 29 '17 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.