`document.currentScript` is more useful than I thought.
Briefly

Familiarity with browser JavaScript APIs varies; some developers may overlook well-established features like document.currentScript. This API offers a reference to the currently executing <script> element, enabling straightforward property access. Despite its utility, document.currentScript is not accessible within modules, returning null instead of undefined, highlighting a design decision in its specification. Reliable support across all major browsers for over a decade means developers can use this feature confidently, representing a valuable tool for JavaScript coders willing to explore the API landscape.
The awareness of an API has less to do with how long it's been around, and more to do with its applicability to the problems we're trying to solve.
document.currentScript provides a reference to the <script> element currently executing the code, allowing access to properties like any other element.
Browser support for document.currentScript is stable; it has been present in all major browsers for over a decade, mitigating compatibility concerns.
Notably, document.currentScript is not available within modules and returns null rather than undefined, a design choice stated in the specification.
Read at Alex MacArthur
[
|
]