@Edent Rather than rewrite anything by hand, why not use a minifier to make that and many other optimisations systematically, eg stripping optional closing tags, sorting attributes and class names, collapsing whitespace, etc...
Edited 43d ago