MinifyHtml Wyam.Minification

Minifies the HTML content.
This module takes the HTML content and uses minification to reduce the output.

Package

This module exists in the Wyam.Minification package which is not part of the core distribution. Add the following preprocessor directive to your configuration file to use it:
#n Wyam.Minification
Alternatively, you can add all modules at once with the following preprocessor directive:
#n Wyam.All

Examples

Pipelines.Add("Content",
    ReadFiles("*.md"),
    FrontMatter(Yaml()),
    Markdown(),
    Razor(),
    MinifyHtml(),
    WriteFiles(".html")
);

Usage

  • MinifyHtml(bool useEmptyMinificationSettings = false)

    Minifies the HTML content.

    • useEmptyMinificationSettings

      Boolean to specify whether to use empty minification settings. Default value is false, this will use commonly accepted settings.

Fluent Methods

Chain these methods together after the constructor to modify behavior.

  • EmptyTagRenderMode(HtmlEmptyTagRenderMode emptyTagRenderMode = null)

    Render mode of HTML empty tag. Can take the following values:

    • NoSlash.Without slash(for example, <br>).
    • Slash.With slash(for example, <br/>).
    • SpaceAndSlash.With space and slash(for example, <br />).

    • emptyTagRenderMode

      Enum type WebMarkupMin.Core.HtmlEmptyTagRenderMode; default value is HtmlEmptyTagRenderMode.NoSlash

  • RemoveHtmlComments(bool removeHtmlComments = true)

    Flag for whether to remove all HTML comments, except conditional, noindex, KnockoutJS containerless comments and AngularJS comment directives.

    • removeHtmlComments

      Default value is true.

  • RemoveOptionalEndTags(bool removeOptionalEndTags = true)

    Flag for whether to remove optional end tags (html, head, body, p, li, dt, dd, rt, rp, optgroup, option, colgroup, thead, tfoot, tbody, tr, th and td).

    • removeOptionalEndTags

      Default value is true.

  • RemoveTagsWithoutContent(bool removeTagsWithoutContent = false)

    Flag for whether to remove tags without content, except for textarea, tr, th and td tags, and tags with class, id, name, role, src and data-* attributes.

    • removeTagsWithoutContent

      Default value is false.

  • WithSettings(Action<HtmlMinificationSettings> action)

    Updates the minification settings.

    • action

      A function to update the minification settings with.

GitHub