Is there a better approach to minify html generated from aspx page
Posted
by Hoque
on Stack Overflow
See other posts from Stack Overflow
or by Hoque
Published on 2010-06-17T15:06:46Z
Indexed on
2010/06/17
15:13 UTC
Read the original article
Hit count: 383
I am using the following code to minify html generated from aspx page duuring runtime.
protected override void Render(HtmlTextWriter writer)
{
TextWriter output = new StringWriter();
base.Render(new HtmlTextWriter(output));
String html = output.ToString();
html = Regex.Replace(html, @"\n|\t", " ");
html = Regex.Replace(html, @">\s+<", "><").Trim();
html = Regex.Replace(html, @"\s{2,}", " ");
writer.Write(html);
}
Is there more better approach to do the same.
Thank you so much.
© Stack Overflow or respective owner