Consider code like the following:
<p> </p><!-- comment -->
<span></span><br />
<div><span class="foo"></span></div>
which on a browser would effectively render as a stretch of whitespace.
I'm wondering if, given that or similar markup, there is a straightforward, programmatic way to detect that the end result of this code with whitespace stripped is an empty string.
The implementation here is JavaScript but I'm also interested in a more general (language agnostic) solution as well if one exists.
Note that just stripping out the tags and seeing if any text remains is not a real fix as there are plenty of tags which do end up rendering visible content (e.g. img, hr, etc).