Something like this works great 0kb added to your bundle :P
Added a feature to techletter.app that lets you click a button to reload a screenshot. But we don't want that button to show up in the final export.
So I started looking for a way to parse HTML. Can't use regex because html is not a regular language ...
So how does this work then? Easy
1) You create a DOM node, no need to render it
2) Set its innerHTML to your input
Browser magically parses that HTML into a DOM tree 👌
You can then do whatever you want using regular DOM manipulation functions. I know you're probably using React, Vue, or whatever so you may have forgotten these exist.
They're still there :)
Once you're done manipulating the DOM, use .innerHTML to get the final output.
And that's how you can use the browser itself to parse and stringify HTML. Feels like a trick but it's great