Created
August 19, 2024 18:16
-
-
Save TravisBernard/60be0407927c3e7aafcd2293fcddd4cf to your computer and use it in GitHub Desktop.
Javascript get path for currently executing script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If script was included using a <script> tag | |
const scriptPath = document.currentScript.src | |
// If the script was included as an ESM module | |
const scriptPath = import.meta.url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment