How may I reference the script tag that loaded the currently-executing script?
How to get the current script element: 1. Use document.currentScript document.currentScript will return the <script> element whose script is currently being processed. <script> var me = document.currentScript; </script> Benefits Simple and explicit. Reliable. Don’t need to modify the script tag Works with asynchronous scripts (defer & async) Works with scripts inserted dynamically Problems Will not … Read more