Last active
December 11, 2020 11:56
-
-
Save turivishal/001530d1fa747e4faf2f612d6c594637 to your computer and use it in GitHub Desktop.
Monify HTML using JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let html = ` | |
Welcome to City | |
<table width="100%" bgcolor="#fff" cellpadding="0" cellspacing="0" border="0"> | |
<tbody> | |
<tr> | |
<td> | |
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth"> | |
<tbody> | |
<tr> | |
<td width="100%"> | |
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth"> | |
<tbody> | |
<tr> | |
<td width="100%" height="10"></td> | |
</tr> | |
<tr> | |
<td width="100%" height="10"></td> | |
</tr> | |
</tbody> | |
</table> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
`; | |
let minifyHtml = html.replace(/^\s+|\r\n|\n|\r|(>)\s+(<)|\s+$/gm, '$1$2'); | |
alert(minifyHtml); | |
console.log(minifyHtml); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment