Skip to content

Instantly share code, notes, and snippets.

@TravisBernard
Created August 19, 2024 18:16
Show Gist options
  • Save TravisBernard/60be0407927c3e7aafcd2293fcddd4cf to your computer and use it in GitHub Desktop.
Save TravisBernard/60be0407927c3e7aafcd2293fcddd4cf to your computer and use it in GitHub Desktop.
Javascript get path for currently executing script
// 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