How to use HTML minification with Web Markup Minifier in NetCore 3.1

 The Web Markup Minifier (abbreviated WebMarkupMin) is a .NET library that contains a set of markup minifiers. The objective of this project is to improve the performance of web applications by reducing the size of HTML, XHTML and XML code.


PM> Install-Package WebMarkupMin.Core -Version 2.8.6 (Detail more at this)

Add In Startup.cs

- ConfigureServices

public void ConfigureServices(IServiceCollection services)

        {

            services.AddWebMarkupMin(

        options =>

        {

            options.AllowMinificationInDevelopmentEnvironment = true;

            options.AllowCompressionInDevelopmentEnvironment = true;

        })

        .AddHtmlMinification(

            options =>

            {

                options.MinificationSettings.RemoveRedundantAttributes = true;

                options.MinificationSettings.RemoveHttpProtocolFromAttributes = true;

                options.MinificationSettings.RemoveHttpsProtocolFromAttributes = true;

            })

        .AddHttpCompression();

        }

- Configure

public void Configure(IApplicationBuilder app, IHostingEnvironment env)

        {

            app.UseWebMarkupMin();

}

Reactions

Post a Comment

0 Comments