Created
March 3, 2020 09:58
-
-
Save kirpalmakanga/8d627f651c1cead2279dd5a238c0ad17 to your computer and use it in GitHub Desktop.
Remove all script tags from html string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stripScripts = (s) => { | |
const div = document.createElement('div'); | |
div.innerHTML = s; | |
const scripts = div.querySelectorAll('script'); | |
for (var script of scripts) { | |
script.parentNode.removeChild(script); | |
} | |
return div.innerHTML; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment