Skip to content

Instantly share code, notes, and snippets.

@round
Created September 21, 2020 19:47
Show Gist options
  • Save round/d1d1552cd978a0850e38ab77def4eece to your computer and use it in GitHub Desktop.
Save round/d1d1552cd978a0850e38ab77def4eece to your computer and use it in GitHub Desktop.
Self unwrapping <script> tag
<script>
var thisScript = document.scripts[document.scripts.length - 1];
var parent = thisScript.parentElement;
const wrapper = document.createElement('div');
wrapper.innerHTML = 'Output';
parent.replaceChild(wrapper.firstChild, thisScript);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment