I have HTML coming from templates that I need to remove spaces between elements and new lines. I don't want to remove spaces that would break the HTML, so it is becoming tricky for me. So far I have the below to remove new lines, but spaces I am stuck on:
'<div id="head"></div> \n <div id="body"></div> <div id="foot"></div> '.replace(/(\r\n|\n|\r)/gm, '');
Is there hopefully something built into jQuery instead of a complex regex maybe to remove the spaces?
/(>)\s+|\s+(<)/.