# list-stylesheets

> Get a list of stylesheets from an HTML document.

Latest version **2.0.2** (published 2024-12-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install list-stylesheets
pnpm add list-stylesheets
yarn add list-stylesheets
bun add list-stylesheets
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2024-12-27 |
| First published | 2015-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 438 |
| Author | Jonathan Kemp |
| Maintainers | jonkemp |
| Keywords | css |

## Links

- npm: https://www.npmjs.com/package/list-stylesheets
- Repository: https://github.com/jonkemp/inline-css.git#master
- Homepage: https://github.com/jonkemp/inline-css/tree/master/packages/list-stylesheets
- Issues: https://github.com/jonkemp/inline-css/issues
- npm.io page: https://npm.io/package/list-stylesheets

## Dependencies (2)

- [cheerio](https://npm.io/package/cheerio.md) 1.0.0
- [pick-util](https://npm.io/package/pick-util.md) ^1.1.5

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2024-12-27
- 2.0.1 — 2023-02-08
- 2.0.0 — 2022-07-08
- 1.2.10 — 2022-01-17
- 1.2.9 — 2020-10-24
- 1.2.8 — 2020-02-21
- 1.2.7 — 2020-01-26
- 1.2.6 — 2020-01-25
- 1.2.5 — 2020-01-25
- 1.2.4 — 2020-01-17
- 1.2.3 — 2019-10-05
- 1.2.2 — 2018-10-24
- 1.2.1 — 2018-03-08
- 1.2.0 — 2018-03-06
- 1.1.1 — 2018-02-20
- … 5 more at https://npm.io/package/list-stylesheets/versions

## README

# list-stylesheets

[![NPM](https://nodei.co/npm/list-stylesheets.png?downloads=true)](https://nodei.co/npm/list-stylesheets/)

> Get a list of stylesheets from an HTML document.

## Install

Install with [npm](https://npmjs.org/package/list-stylesheets)

```
npm install --save list-stylesheets
```

## Usage

```js
var getStylesheetList = require('list-stylesheets');

var data = getStylesheetList(html, options);

console.log(data.html);
console.log(data.hrefs);
```

## API

### getStylesheetList(html, options)

#### options.applyLinkTags

Type: `Boolean`  
Default: `true`

Whether to resolve `<link rel="stylesheet">` tags and inline the resulting styles.

#### options.removeLinkTags

Type: `Boolean`  
Default: `true`

Whether to remove the original `<link rel="stylesheet">` tags after (possibly) inlining the css from them.

#### options.codeBlocks

Type: `Object`  
Default: `{ EJS: { start: '<%', end: '%>' }, HBS: { start: '{{', end: '}}' } }`

An object where each value has a `start` and `end` to specify fenced code blocks that should be ignored during parsing. For example, Handlebars (hbs) templates are `HBS: {start: '{{', end: '}}'}`. Note that `codeBlocks` is a dictionary which can contain many different code blocks, so don't do `codeBlocks: {...}` do `codeBlocks.myBlock = {...}`.

### cheerio options

Options to passed to [cheerio](https://github.com/cheeriojs/cheerio).

## Credit

The code for this module was originally taken from the [Juice](https://github.com/Automattic/juice) library.

## License

MIT © [Jonathan Kemp](http://jonkemp.com)

---
_Source: https://npm.io/package/list-stylesheets · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
