Skip to content

JKamsker/NMinify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NMinify logo

Minify HTML, CSS, JS and more

NuGet version (NMinify) Nuget GitHub Workflow Status GitHub license PR

Introduction

NMinify is a Wrapper for the golang library minify.
Minification is the process of removing bytes from a file (such as whitespace) without changing its output and therefore shrinking its size and speeding up transmission over the internet and possibly parsing. The implemented minifiers are designed for high performance.

Installation

To install NMinify, run the following command in the Package Manager Console:

Install-Package NMinify

You can also install NMinify via the .NET CLI by running:

dotnet add package NMinify

Alternatively, you can add NMinify as a dependency in your project's .csproj file:

<ItemGroup>
  <PackageReference Include="NMinify" Version="x.x.x" />
</ItemGroup>

Make sure to replace x.x.x with the latest version available on NuGet.

Once NMinify is installed, you can start using it in your project by adding using NMinify; to the top of your file.

Basic Usage

var text = "<span style=\"color:#ff0000;\" class=\"text\">Some  text</span>";
var minifier = new Minifier();
var minified = minifier.MinifyString(MinifierMediaType.Html, text);


Console.WriteLine(text); // Output: <span style="color:#ff0000;" class="text">Some  text</span>
Console.WriteLine(minified); // Output: <span style=color:red class=text>Some text</span>

Available Methods

Span<byte> MinifyBytes(MinifierMediaType mediaType, ReadOnlySpan<byte> input, Span<byte> output);
string MinifyFile(string mediatype, string input);
string MinifyString(MinifierMediaType mediaType, string input);

License

NMinify is released under the MIT License. This means that you are free to use, modify, and distribute this software as long as you include the original copyright and license notice in your distribution.

Please note that the underlying minify library by tdewolff is also released under the MIT License, and its copyright and license must also be included in any distribution of NMinify.

By using NMinify, you are agreeing to the terms of the MIT License. If you do not agree to these terms, you should not use this software.


Made with stackedit.io, minify and lots of ❤️ in Austria