Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string-uglify

codsen100.2kMIT3.0.13TypeScript support: included

Shorten sets of strings deterministically, to be git-friendly

class, classes, css, generate, generator, id, minify, name, names, reference, selector, short, string, style, uglify, values

readme

string-uglify

Shorten sets of strings deterministically, to be git-friendly

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 1.5.0 (npm i string-uglify@1.5.0).

npm i string-uglify

Quick Take

import { strict as assert } from "assert";

import { uglifyById, uglifyArr, version } from "string-uglify";

// notice we put dots and hashes for classes and id's but algorithm will work
// fine too if you won't.
const names = [
  ".module-promo-all",
  ".module-promo-main",
  ".module-promo-second",
  "#zzz",
];

// notice we put dots and hashes for classes and id's but algorithm will work
// fine too if you won't.
assert.deepEqual(uglifyArr(names), [".o", ".s", ".z", "#l"]);

// uglify a particular id number (inefficient):
assert.equal(uglifyById(names, 3), "#l");

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

3.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

2.1.0 (2022-08-12)

Features

2.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

1.5.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

1.4.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

1.4.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

1.4.0 (2021-01-23)

Features

1.2.0 (2019-06-29)

Features

  • Uglifies to single letter names by shortening to first letter (02cb90b)

1.1.0 (2019-06-22)

Features

  • Fully recode the algorithm to make it 99.9% resilient to positional reference array changes (5c364a8)

1.0.0 (2019-06-21)

  • First public release