0

i need to add a JS script in the admin HEADER tag in the admin section for all pages. how to do that?

2

Create default.xml in your own module.

Path:

app/code/Name_Space/Module_Name/view/adminhtml/layout/default.xml

And put below code:

<?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">
   <head>
     <script src="module_name::js/customjsfile.js"/>
   </head>
</page>
  • thanks, and where to save "customjsfile.js"? – Zorox May 14 '18 at 13:08
  • It should under app/code/Name_Space/Module_Name/view/adminhtml/web/js folder. – kunj May 14 '18 at 13:11
  • ONE PROBLEM, how to add a remote script? LOOKS like magetno alwasy try to use local scripts and add the website root URL before the src – Zorox May 14 '18 at 13:16
  • <script src="google.com/yourscript.js" src_type="url" /> – Vithal Bariya May 14 '18 at 13:24
  • perfect. worked well – Zorox May 14 '18 at 13:55

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.