DEV Community

Paboda Hettiarachchi
Paboda Hettiarachchi

Posted on

1

Adding a custom js to backend - Magento 2

To add a JS througout backend in Magento, I followed the following method.

1.Add the head tag in Paboda/Demo/view/adminhtml/layout/default.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="Paboda_Demo::js/lib/custom.js"/>
    </head>
</page>
Enter fullscreen mode Exit fullscreen mode

2.Add the custom.js file to the following path Paboda/Demo/view/adminhtml/web/js/lib/custom.js

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay