Skip to content

Instantly share code, notes, and snippets.

@pavelbinar
Created June 17, 2020 13:31
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 pavelbinar/b5c4812bff1db02704f1b9cd212c8f0c to your computer and use it in GitHub Desktop.
Save pavelbinar/b5c4812bff1db02704f1b9cd212c8f0c to your computer and use it in GitHub Desktop.
Dynamically add script tag with unique src
<script>
var now = new Date().getTime();
var newScript = document.createElement("script");
newScript.src = "<%= htmlWebpackPlugin.options.mainURL %>?t=" + now;
var target = document.getElementsByTagName("body")[0];
target.appendChild(newScript);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment