B
Brian W
....or would you?
In order to minimize the number of bytes a pages consists of (to minimize
download time), and, admittedly, to disguise my HTML a little, all my pages
derive from a base class that I derived from Page.
In this class I override the Render method and do what is shown in the code
fragment below.
My intent is to remove all the stuff that doesn't affect the HTML output,
but this method does have it's problems.
1 ) When I newline or tab is in place that causes a space to be created
between words and when removed causes unwanted concatenation.
2 ) It doesn't take into consideration tags where these characters are
significant, such as in <pre> tags or script code.
Any thoughts?
TIA
Brian W
// Begin code fragment
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
base.Render (hw);
string html = sb.ToString();
if ( CompressOutput )
{
html = html.Replace(Environment.NewLine, string.Empty);
html = html.Replace("\n", string.Empty); // This may be redundant
html = html.Replace("\t", string.Empty);
}
writer.Write(html);
}
// End code fragment
In order to minimize the number of bytes a pages consists of (to minimize
download time), and, admittedly, to disguise my HTML a little, all my pages
derive from a base class that I derived from Page.
In this class I override the Render method and do what is shown in the code
fragment below.
My intent is to remove all the stuff that doesn't affect the HTML output,
but this method does have it's problems.
1 ) When I newline or tab is in place that causes a space to be created
between words and when removed causes unwanted concatenation.
2 ) It doesn't take into consideration tags where these characters are
significant, such as in <pre> tags or script code.
Any thoughts?
TIA
Brian W
// Begin code fragment
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
base.Render (hw);
string html = sb.ToString();
if ( CompressOutput )
{
html = html.Replace(Environment.NewLine, string.Empty);
html = html.Replace("\n", string.Empty); // This may be redundant
html = html.Replace("\t", string.Empty);
}
writer.Write(html);
}
// End code fragment