3 ms·
I think there is a better way. 1. Add package called `WebMarkupMin.AspNetCore2`. 2. Add and configure code in your `Startup.cs` like so. services.AddWebMar
by romanovcode 8y ago
I think there is a better way.
1. Add package called `WebMarkupMin.AspNetCore2`.
2. Add and configure code in your `Startup.cs` like so.
services.AddWebMarkupMin(
options =>
{
options.AllowMinificationInDevelopmentEnvironment = true;
options.AllowCompressionInDevelopmentEnvironment = true;
options.DisablePoweredByHttpHeaders = true;
})
.AddHtmlMinification(
options =>
{
options.MinificationSettings.RemoveRedundantAttributes = true;
options.MinificationSettings.RemoveHttpProtocolFromAttributes = true;
options.MinificationSettings.RemoveHttpsProtocolFromAttributes = true;
// More options if you like so
})
.AddHttpCompression();
Not only will this minfy HTML output, but also apply a lot more optimisations based on your configuration.
- bobblywobbles 8y agoI'm open to adding more of the options that WebMarkupMin provide. The main difference between this and WebMarkupMin is that WebMarkupMin runs at runtime - therefore it is costing time to minify when you can already minify the files before launching your web application.
- romanovcode 8y agoYeah, that is true. However that HTML is usually cached so not a big deal. Also, this reduces complexity of the project. Both methods are fine, it's just I prefer this one.