Skip to content

Instantly share code, notes, and snippets.

@MikeNGarrett
Created February 28, 2023 16:49
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 MikeNGarrett/7d85c536369e8b9e7689e2072f15327e to your computer and use it in GitHub Desktop.
Save MikeNGarrett/7d85c536369e8b9e7689e2072f15327e to your computer and use it in GitHub Desktop.
Conditionally changing script src
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
</head>
<body>
<script type="module">
const condition = window.location.host == 'apexofacircle.github.io';
await import(condition ? '/GithubShop/script.js' : '/script.js')
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment