NUglify 1.21.18

Prefix Reserved
dotnet add package NUglify --version 1.21.18
                    
NuGet\Install-Package NUglify -Version 1.21.18
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NUglify" Version="1.21.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NUglify" Version="1.21.18" />
                    
Directory.Packages.props
<PackageReference Include="NUglify" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NUglify --version 1.21.18
                    
#r "nuget: NUglify, 1.21.18"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NUglify@1.21.18
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NUglify&version=1.21.18
                    
Install as a Cake Addin
#tool nuget:?package=NUglify&version=1.21.18
                    
Install as a Cake Tool

NUglify CI NuGet

NUglify provides minify and compression methods for CSS, JavaScript and HTML files.

This repository is a fork of the Microsoft Ajax Minifier + additional features (e.g: HTML compressor)

While dotnet Core is now relying on the node.js ecosystem for its client side tooling (e.g: minify), NUglify is still useful in scenarios where we need to access this tooling from a .NET application (not necessarily an ASP one) without having to install another developer platform.

The original AjaxMin documentation of the project is available here

See the ChangeLog

Features

  • JS minification
    • Fully ES2020 + ES2021 compliant
  • Css minification
  • HTML minification
    • Can help to reduce by 5-10% a standard HTML document
    • Supports several minifications methods: remove comments, collapse whitespaces, remove optional tags (p, li...), remove quoted attributes, remove specific attributes, decode HTML entities, compress inline style and script using NUglify
    • No regex involved, full HTML parser
    • Supports HTML5, works best on valid HTML documents (but can still work on invalid documents)
    • Similar to the popular html-minifier in JS
    • Super fast and GC friendly parser and minifier, 10x times faster than existing html compressor for .NET
    • Method Uglify.HtmlToText that allows to extract the text from an HTML document
  • Compatible with .NET Framework 4.0, .NET Standard 2.0, and .NET 10.0

Download

NUglify is available as a NuGet package: NuGet

Usage

Basic usage

The main entry point for the API is the Uglify class:

For JavaScript:

var result = Uglify.Js("var x = 5; var y = 6;");
Console.WriteLine(result.Code);   // prints: var x=5,y=6

For Css:

var result = Uglify.Css("div { color: #FFF; }");
Console.WriteLine(result.Code);   // prints: div{color:#fff}

For Html:

var result = Uglify.Html("<div>  <p>This is <em>   a text    </em></p>   </div>");
Console.WriteLine(result.Code);   // prints: <div><p>This is <em>a text</em></div>

Extract text from Html:

var result = Uglify.HtmlToText("<div>  <p>This is <em>   a text    </em></p>   </div>");
Console.WriteLine(result.Code);   // prints: This is a text

HTML

See the xmldoc comments on the properties of NUglify.Html.HtmlSettings for all your HTML minification needs.

For example, to output indented (with tabs) HTML:

var htmlSettings = HtmlSettings.Pretty();
htmlSettings.Indent = "\t";
var output = Uglify.Html(input, htmlSettings);

JS

TODO

CSS

TODO

Known Issues

See the issues pages on github, however the only real known issue is:

If you overload the async keyword as an identifier, like so:

function (async) {
    async = 1; // this will work
    async[1] = 2; // this will work
    async(); // this line will be stripped
    async(a,b); // this will end up as: a,b
}

you'll see the commented behaviour. This is a difficult job to fix, but PRs welcome. I don't think this is a worth the effort to fix right now, you've got to be a real sadist to be doing this to yourself in the first place. See #130 if you want to try and fix it yourself.

Questions

  • Can we collaborate with a project like Jint to leverage on a common JavaScript parser infrastructure?
  • Can we utilise AngleSharp for the HTML/Css minification?

License

This package includes the repository license.txt file, which covers the BSD 2-Clause terms for NUglify and the original Apache 2.0 notice for Microsoft Ajax Minifier.

Author

Microsoft Ajax Minifier was created and maintained by Ron Logan, with contributions from Eugene Chigirinskiy, Rafael Correa, Kristoffer Henriksson, and Marcin Dobosz.

Nuglify was ported and refactored to github by Alexandre Mutel aka xoofx

It is now maintained by Jason Best aka jbest84

Previous Maintainers

Andrew Bullock aka trullock

Credits

The logo Monster is by Joel McKinney from the Noun Project

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages (146)

Showing the top 5 NuGet packages that depend on NUglify:

Package Downloads
Volo.Abp.Minify

Package Description

Abp.Web.Common

Abp.Web.Common

Smidge.Nuglify

A Nuglify engine for Smidge

LigerShark.WebOptimizer.Core

A runtime bundler and minifier for ASP.NET Core

BundlerMinifier.Core

Bundles and minifies CSS, JS and HTML files

GitHub repositories (28)

Showing the top 20 popular GitHub repositories that depend on NUglify:

Repository Stars
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
BililiveRecorder/BililiveRecorder
录播姬 | mikufans 生放送录制
ONLYOFFICE/CommunityServer
Free open source office suite with business productivity tools: document and project management, CRM, mail aggregator.
serenity-is/Serenity
Business Apps Made Simple with Asp.Net Core MVC / TypeScript
smartstore/SmartStoreNET
Open Source ASP.NET MVC Enterprise eCommerce Shopping Cart Solution
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 10
microsoft/VSSDK-Extensibility-Samples
Samples for building your own Visual Studio extensions
ligershark/WebOptimizer
A bundler and minifier for ASP.NET Core
aelassas/wexflow
Workflow Automation Engine
bdovaz/UnityNuGet
Provides a service to install NuGet packages into a Unity project via the Unity Package Manager
madskristensen/BundlerMinifier
Visual Studio extension
Code52/pretzel
A site generation tool (and then some) for .NET platforms
CodeBeamOrg/CodeBeam.MudBlazor.Extensions
Useful third party extension components for MudBlazor, from the contributors.
Taritsyn/WebMarkupMin
The Web Markup Minifier (abbreviated WebMarkupMin) - 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.
madskristensen/WebCompiler
Visual Studio extension for compiling LESS and Sass files
Valour-Software/Valour
Valour is bringing communities into the future with unique features, blazing performance, and respect for users.
Shazwazza/Smidge
A lightweight runtime CSS/JavaScript file minification, combination, compression & management library for ASP.Net Core
pebakery/pebakery
PEBakery is a script engine that specializes in customizing the Windows Preinstalled Environment (WinPE/WinRE).
Kooboo/Kooboo
CMS, WebSite, Application and Ecommerce Development Tool Using JavaScript
Version Downloads Last Updated
1.21.18 1,329 7/8/2026
1.21.17 1,686,395 7/29/2025
1.21.16 4,963 7/29/2025
1.21.15 3,228,324 4/7/2025
1.21.14 17,728 3/31/2025
1.21.13 171,499 2/27/2025
1.21.12 56,730 2/22/2025
1.21.11 367,352 12/10/2024
1.21.10 1,321,337 11/4/2024
1.21.9 5,081,147 6/24/2024
1.21.8 89,382 6/11/2024
1.21.7 398,860 4/24/2024
1.21.5 4,194 4/24/2024
1.21.4 2,661,979 2/5/2024
1.21.3 6,710 2/4/2024
1.21.2 499,611 12/16/2023
1.21.0 4,199,392 10/6/2023
1.20.7 3,638,757 5/11/2023
1.20.6 347,983 4/4/2023
1.20.5 681,278 1/26/2023
Loading failed