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

Package detail

email-comb

codsen151.1kMIT7.0.25TypeScript support: included

Remove unused CSS from email templates

body, css, email, from, head, inline, remove, styles, uncss, unused

readme

email-comb

Remove unused CSS from email templates

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

Install

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

npm i email-comb

Quick Take

import { strict as assert } from "assert";
import { comb, defaults, version } from "email-comb";

const source = `<head>
<style type="text/css">
.unused1[z] {a:1;}
.used[z] {a:2;}
</style>
</head>
<body class="  used  "><a class="used unused3">z</a>
</body>
`;

const intended = `<head>
<style type="text/css">
.used[z] {a:2;}
</style>
</head>
<body class="used"><a class="used">z</a>
</body>
`;

assert.equal(comb(source).result, intended);

Documentation

Please visit codsen.com for a full description of the API. Also, try the GUI playground.

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.

7.0.24 (2025-02-28)

Bug Fixes

  • fix rogue comma leftover after certain conditions (6ebd5cd), closes #102

7.0.16 (2023-07-14)

Bug Fixes

  • algorithm misinterpreting CSS comments in URL pattern in text (0b8a520), closes #83

5.3.0 (2023-05-21)

Features

  • back-porting the latest v7.0.13 to CJS and releasing as non-pure ESM (no type: module in package.json).

7.0.13 (2023-05-15)

Bug Fixes

7.0.11 (2023-04-16)

Bug Fixes

  • trailing line break to be correctly set in CR files (849ff16)

7.0.0 (2022-12-01)

BREAKING CHANGES

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

6.3.0 (2022-08-18)

Features

  • fix result log.originalLength (994b27d)

6.2.0 (2022-08-12)

Features

6.1.22 (2022-08-04)

Fixed

  • export Opts and Res types (398a7d1)

6.1.18 (2022-07-13)

Fixed

  • fix a bug where selectors ending with colon were misinterpreted (f279a19)

6.1.14 (2022-04-18)

Fixed

6.1.8 (2022-01-11)

Fixed

  • add safeguards against inputs containing excessive whitespace (4694257), closes #35

6.1.0 (2021-11-04)

Features

  • extend opts.whitelist to match against the whole chunk (52855ad), closes #27

6.0.0 (2021-09-09)

Features

BREAKING CHANGES

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

5.0.14 (2021-04-04)

Fixed

5.0.7 (2021-03-07)

Fixed

  • correct the name of the package in the throw messages (2d1ad58)

5.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

5.0.0 (2021-01-23)

Features

BREAKING CHANGES

  • Now you must consume like import { comb } from ...

4.1.0 (2020-12-11)

Features

  • leave quote-less attributes intact, don't try to restore quotes (cf591db)

4.0.5 (2020-12-09)

Fixed

  • correct the typo in the log.timeTakenInMilliseconds (ddc2dec)

4.0.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

3.10.6 (2020-11-02)

Fixed

  • interpret id= or class= in URLs as text (547cf93), closes #45

3.10.0 (2020-09-15)

Features

  • leave the trailing line break condition as it comes in, unless it's excessive (trim then) (f2dee90), closes #40

3.9.20 (2020-08-08)

Fixed

  • fix a bug with consecutive style tags ignored first class' first char (758ea97), closes #36

3.9.17 (2020-05-24)

Fixed

  • stop removing class or id without following equals, completely (for now) (c07cce5), closes #27

3.9.0 (2020-01-26)

Features

  • improvements to algorithm when class is joined with a known ESP tag (366c13b)

3.8.0 (2019-09-17)

Fixed

  • correctly recognise single and double apostrophes within the text, outside tags (5f7f428)

Features

  • recognise single-double-single/double-single-double quotes within attr values (3eeaf1e)

3.7.1 (2019-09-11)

Fixed

  • remove leading spaces in cleaned like class=" zz" and tighten up class/id recognition (a900e4e)

3.7.0 (2019-09-04)

Features

  • recognise bracket notation (ce0a0b1)

3.6.0 (2019-08-24)

Features

  • support quoteless attributes that come out of other minifiers (9129fad)

3.5.0 (2019-08-08)

Features

  • support for liquid template engine double curlies as CSS style values in head CSS (819df36)

3.4.0 (2019-06-29)

Features

  • Add perf measurement, comparing and recording (44f7a9e)

3.3.0 (2019-06-25)

Features

  • Output object's new keys countBeforeCleaning and countAfterCleaning (55b13e7)
  • Uglification legend does not mention entries which were not uglified because of being whitelisted (b6bacfc)

3.2.0 (2019-06-21)

Features

  • opts.removeCSSComments (b848d1c)
  • Uglification based on class/id characters but not class/id position in the reference array (c839977)

3.1.0 (2019-06-18)

Features

  • If uglification was turned on, output legend under log.uglified (805ce2d)
  • opts.reportProgressFunc (f5935fb)
  • opts.reportProgressFuncFrom and opts.reportProgressFuncTo (8734cc5)

3.0.0 (2019-06-01)

Features

  • Change the default export to { comb } instead of function exported as default (3db706e)

BREAKING CHANGES

  • Now you must consume importing or requiring { comb } instead of assigning to any variable you like as before

2.0.10 (2019-03-22)

Fixed

  • The comma bug where unused chunk was sandwiched by used chunks (cb6fa4c)

1.2.8 (2019-02-26)

Fixed

  • Empty media queries in tight scenarios not being removed completely (d4f1d8e)

1.2.7 (2019-02-10)

Fixed

  • Fix the Create New Issue URLs (c5ee4a6)

1.2.0 (2019-01-20)

  • Various documentation and setup tweaks after we migrated to monorepo
  • Setup refresh: updated dependencies and all config files using automated tools

1.0.0 (2018-12-15)

  • Renaming email-remove-unused-css to email-comb and resetting versions to 1.0.0