i need to add a JS script in the admin HEADER tag in the admin section for all pages. how to do that?
1 Answer
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>
-
-
It should under
app/code/Name_Space/Module_Name/view/adminhtml/web/js
folder.– kunjCommented May 14, 2018 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– ZoroxCommented May 14, 2018 at 13:16
-
<script src="google.com/yourscript.js" src_type="url" /> Commented May 14, 2018 at 13:24
-