“How to replace an element and its content using vanilla JS - Go Make Things”
On sites with user-generated content I like to use Node.replaceWith() in conjunction with DOMPurify configured it to return a DocumentFragment.
... works as a web developer in Hveragerði, Iceland, and writes about the web, digital publishing, and web/product development
These are his notes
“How to replace an element and its content using vanilla JS - Go Make Things”
On sites with user-generated content I like to use Node.replaceWith() in conjunction with DOMPurify configured it to return a DocumentFragment.