Skip to content

Instantly share code, notes, and snippets.

@donpark
Last active June 23, 2020 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donpark/5c633bcd0ead47d81782c7030d3741ae to your computer and use it in GitHub Desktop.
Save donpark/5c633bcd0ead47d81782c7030d3741ae to your computer and use it in GitHub Desktop.
scriptBaseUrl
// This needs to run when script loads.
const scriptUrl = new URL(document.currentScript.src, document.baseURI).toString();
const scriptBaseUrl = scriptUrl.substr(0, scriptUrl.lastIndexOf('/'));
// To build URL relative to script file.
const wasm = `${scriptBaseUrl}/wasm/my.wasm`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment