remove useless nodes (whitespaces,comments etc) from DOM

From http://www.sitepoint.com/removing-useless-nodes-from-the-dom/