My custom module can add JS to all admin pages, but I only want to add the JS to product pages I am editing.

I have my XML: view/adminhtml/layout/default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
     <script src="module_namespace::js/priceChange.js"/>

and my JS: view/adminhtml/web/js/priceChange.js

Wondering if I need to change the path, the XML or both?

1 Answer 1


I needed to change the name of the XML to catalog_product_edit.xml This was figured out by checking out the vendor/magento/module-catalog/view/adminhtml/layout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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