HtmlMinifier Class

Namespace
Kampute.DocToolkit.IO.Minifiers
Assembly
  • Kampute.DocToolkit.dll

Definition

A TextWriter that wraps another TextWriter that outputs well-formed HTML content, minifying it by removing unnecessary whitespace and comments, while preserving whitespace within <pre> elements.
public class HtmlMinifier : WrappedTextWriter
Inheritance

Remarks

The HtmlMinifier processes HTML content character by character, optimizing it by removing unnecessary whitespace and comments while preserving essential formatting, particularly within <pre> elements. This results in a more compact HTML output suitable for production use and bandwidth-sensitive scenarios.
This writer assumes well-formed HTML input. Malformed or improperly structured HTML may lead to unexpected minification behavior and potentially corrupt output.

Thread Safety

Public static members of the type are guaranteed to be thread-safe. However, public instance members are not thread-safe.

Constructors

HtmlMinifier(TextWriter, bool)Initializes a new instance of the HtmlMinifier class.

Properties

InlineTagsGets the set of HTML tags that are considered inline elements.
PreformattedTagsGets the set of HTML tags that are considered pre-formatted elements.
PreserveAttributeWhitespaceGets or sets a value indicating whether to preserve whitespace within attribute values.
PreserveCommentsGets or sets a value indicating whether to preserve comments within the HTML content.

Methods

Write(char)Processes and writes a single character.