A simple jQuery function that removes empty or tags containing just '&nbsp;'
"This isn't exactly DRY" is pretty much what I think about


$(this).text().trim() == '&amp;nbsp;' || $(this).text().trim() === ''



text() can be a very expensive call: I would refactor to only do $(this).text().trim() once.



As a minor concern, the use of trim() suggests that you want to remove nodes whose text is purely whitespace. So shouldn't a node whose text is &amp;nsbp; &amp;nbsp; be removed? Perhaps you should be using a regex match instead of trim()? Something like (warning: untested) $(this).text().match(/^(\s|&amp;nbsp;)*$/).

And then you could take it further: &amp;nbsp; isn't the only way of escaping U+00a0, and the other whitespace characters can also be escaped in various ways...