npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

uglicssy

v0.5.1

Published

Npm package for minifying CSS class names.

Downloads

13

Readme

uglicssy

NPM package for minifying CSS class names.

This package minifies CSS, JS and HTML code but most of all it also minifies CSS class names.


Installation

npm i uglicssy --save-dev

Usage

  • CLI

    $ uglicssy [options] <input_file...>

    Convert a single file. The converted code will be saved as a new file with the uglicssy suffix.

    $ uglicssy styles.css

    Convert a directory. All files will be converted recursively.

    $ uglicssy src
    options

    You can use the following bash style options:

    option | shortcut | description ------ | -------- | ----------- --verbose | -v | verbose mode

  • Script

    You can load the Uglicssy class as a module:

    const Uglicssy = require('uglicssy');

    It is an ES6 class with the following methods:

    • public static bundle() : Uglicssy

      This is a static method which returns a new instance of Uglicssy class. Keep reference to that instance in order to process multiple files in the runtime.

    • public convert(inputString : String, fileType : String[, save : Boolean]) : String

      This is the main method for converting the code.

      • inputString is a string with CSS, HTML or JS code
      • fileType must be one of the following strings:
        • css
        • html
        • js
      • save (default: true) boolean value indicating whether the modified classes array should be immediately saved (see the save method below).
    • public save() : undefined

      This method saves the current classes array synchronously to the output file specified in the .uglicssyrc. If the file is not specified, the method performs noop. It is useful if you want to convert multiple files in a runtime without modifying the classes file in each iteration.


    A full example

    In order to use Uglicssy inside your script, first you need to get its new instance (bundle) which will store all class names (and their minified versions) encountered during converting.

    const Uglicssy = require('uglicssy');
    const cssString = '.foo .bar { display: block; } ...';
      
    const bundle = Uglicssy.bundle();
    const convertedString = bundle.convert(cssString, 'css');

What about JS?

By default, uglicssy converts CSS and HTML code but it does very little when it comes to JavaScript. It doesn't try to guess which string literals might be class names. If you want uglicssy to treat a certain string literal as a CSS class name (or CSS selector) you have to preced it with a comment:

const stringLiteral = 'This is a literal. It will not be treated as a CSS class';

//uglicssy
const className = 'foo'; //uglicssy will treat `foo` as a CSS class name

//uglicssy
const cssSelector = '.foo .bar > p'; //uglicssy will treat `foo` and `bar` as a CSS class names

Configuration (.uglicssyrc)

{
  "outputFile": "uglicssy.json",
  "presets": ["uglicssy-preset-angular", "uglicssy-preset-jquery"]
}

You can add a configuration file .uglicssyrc to your project's root folder. It must be a JSON file and it accepts the following options:

  • outputFile

    File path where you want the class names and other metadata to be saved. It is useful when you want to convert multiple files but are unable to do it in a single runtime.

  • presets

    Thanks to presets, you can add new rules to uglicssy. For example, a uglicssy-preset-angular preset can parse ng-class attributes and convert classes contained there.

    To use a preset, first you need to install it. Names of presets in the config file are the names of their NPM packages, e.g. to install uglicssy-preset-angular you need to

    npm i uglicssy-preset-angular --save-dev
  • verbose

    When this option is set to true every class conversion will be described in the console.