JavaScript: get the current executing node? [duplicate]

Modern browsers support a standard property on document object that points to the current script node:

https://developer.mozilla.org/en-US/docs/DOM/document.currentScript

<script id="x">
  console.log(document.currentScript.id); // << this must return "x"
</script>

Leave a Comment