Minify Tag Helper

The minify tag helper minifies the html contents of the element it is applied to. It removes unnecessary whitespace, which improves page size and download speed. Minification can be applied to the whole page, or on specific elements.

HTML minification can sometimes lead to unexpected side effects, such as JavaScript or CSS not working as intended. Always check your website for bugs after enabling minification.

Usage

The minify tag helper can be used with any html element. Add the following attributes to enable html minification:

  • re-minify - boolean value specifying if minification should be enabled.
  • re-minify-if-environment - comma-separated list of environment names, e.g. "Development,Staging". Minification will only occur if the list contains the current environment name. Can be used without explicitly setting re-minify.

Examples

<html>
    <head re-minify="true">
        <title>Minification Example - Redakt CMS</title>
    </head>

    <body>
        <div class="header" re-minify-if-environment="Production">
        </div>

        <div class="article" re-minify="@SomeCheck()">
        </div>
    </body>
</html>