Skip to content

Instantly share code, notes, and snippets.

@James-E-A
Created June 30, 2025 20:53
Show Gist options
  • Save James-E-A/ed7e346bf57011a55b07bbe782dc5271 to your computer and use it in GitHub Desktop.
Save James-E-A/ed7e346bf57011a55b07bbe782dc5271 to your computer and use it in GitHub Desktop.
Javascript currentScript async
<script type="text/javascript">(async () => {
const currentScript = document.currentScript; // scoped to this IIFE, does not pollute global namespace or vanish on future event loop ticks
// You are 100% free to do async stuff in this block
console.info(await 42);
// ... //
})().then((value) => {if (value) !== undefined console.debug(value);});</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment