HtmlFormat.CreateMinifier Method

Namespace
Kampute.DocToolkit.Formatters
Assembly
  • Kampute.DocToolkit.dll

Definition

Creates a TextWriter instance that wraps the specified writer to minimize the content for HTML format.
public override TextWriter CreateMinifier(TextWriter writer)

Parameters

writer TextWriter
The TextWriter to write the minimized content to.

Returns

TextWriter
An HtmlMinifier instance that wraps the specified writer for minimizing HTML content.

Remarks

This implementation creates an HtmlMinifier that performs HTML-specific optimizations such as:
  • Removing unnecessary whitespace between HTML tags
  • Preserving whitespace in <pre> elements and other sensitive contexts
  • Normalizing line breaks and indentation
  • Maintaining valid HTML structure while reducing file size
The minification process reduces the size of HTML output without affecting its rendering or structure, making it ideal for production environments where bandwidth optimization is important.
After calling this method, the caller should not write to, close, or dispose the original writer directly to ensure that the minimized content is written correctly.
It is the caller's responsibility to dispose the returned MarkupWriter instance to release any resources.