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


Create default.xml in your own module.



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">
     <script src="module_name::js/customjsfile.js"/>
  • 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.