I'm adding a script to my page:
<script src="https://example.com/script.js"/>
But I would like to be able to pass a "key" to this script as it's being loaded, the key needs to be accessible by the loaded script, as it depends on it.
How can I do this?
Ideally something like this would be great:
<script src="https://example.com/script.js?key=authkey"/>
But I can't find much on getting this to work.
So far I've been adding an extra meta tag:
<meta
name="key"
content={"authkey"}
/>
And accessing it from the script:
const key = document.getElementsByName("key")[0].content;
But this isn't great. I also found this answer but it's not much better.