I haven't found any mentions in the HTML spec nor anywhere on the web, that says this is possible, still I ask just in case.
Is it possible to get the URL of a module to for example fetch files relative to that URL?
Let's say my index.html
has a:
<script type="module">import '/foo/foo.js'</script>
and foo.js
wants to know what it's own url is to load dynamically some file e.g. ./file-inside-foo
.
As of the time of this writing document.currentScript
returns null
inside modules and is probably like that by design?