Hi!
I’m sure I am missing something but I can’t figure out how to inject plain js script into head, on admin side?
I just want to add a <script src="something.js">
into <head>
Ideally, I’d like to add this override from a plugin.
Thank you!
This topic has been created from a Discord post (1300387581816471615) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord
Indeed, I was just missing a simple thing. I past the answer here, just in case it can helps:
It is possible to deal with the useEffect
directive to add the script element, from a component :
// Add scripts
useEffect(() => {
const script = document.createElement('script');
script.src = "url/of/the/wanted/script.js";
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
}, []);