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. Script tags are never minified.

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. Typically it is set on the body or HTML tag to minify the whole page. Add the following attributes to enable HTML minification:

  • rx-minify - boolean value specifying if minification should be enabled.
  • rx-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 rx-minify.

Examples

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

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

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