Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (9 sloc) 1.68 KB

HTML Integration for import.meta

We hope to eventually introduce two properties onto import.meta in web browsers, via the the HTML Standard.

import.meta.url

This property will contain the module script's base URL, serialized.

A specification pull request exists at whatwg/html#3141 for this. (It's pretty straightforward.)

import.meta.scriptElement

This property will contain the <script> element that initiated the fetching of the current module, if any. It is meant to be a more robust replacement for document.currentScript. See whatwg/html#1013 for the genesis of the idea.

However, specifying this is harder than you might imagine. For example, a given module script can be contained in multiple graphs with different root <script> elements, and which one caused it to instantiate or evaluate could be nondeterministic. There is also a concern that introducing such a long-lived pointer to the <script> element could be a memory leak.

These concerns are being discussed in the aforementioned thread. In the meantime, you can look at the old design we proposed for import.meta.scriptElement by checking out an older draft of this document. In light of the above, it was not properly thought through, so this is just for historical reference.

You can’t perform that action at this time.