# collapsify

> Inlines all of the JavaScripts, stylesheets, images, fonts etc. of an HTML page.

Latest version **0.8.0** (published 2023-05-22) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install collapsify
pnpm add collapsify
yarn add collapsify
bun add collapsify
```

Provides the command `collapsify`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2023-05-22 |
| First published | 2012-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 213 |
| Author | Terin Stock |
| Maintainers | cf-radar, dash_service_account, trevorcf, g4brym, snigdha34, wrangler-publisher, marksteyn, chiminator, sgoodhew_cf, terinjokes, third774, evanderkoogh, jsteinberger, jasnell, kkoenig, asapzacy, pcostanzo, gregbrimble, geelen, jgentes, rexscaria, dcruz_cf, xuranwang, jculvey, sejoker, caass, vasturiano, cf-ci-write, segments-write, thibmeu, xortive, gurjinder, cf-ci2, lvalenta, worenga, cdata |
| Keywords | html, stylesheet, font, css, javascript, js, compile, inline, mobilize, optimize, optimization |

## Links

- npm: https://www.npmjs.com/package/collapsify
- Repository: https://github.com/cloudflare/collapsify
- Homepage: http://github.com/cloudflare/collapsify
- Issues: http://github.com/cloudflare/collapsify/issues
- npm.io page: https://npm.io/package/collapsify

## Dependencies (9)

- [bole](https://npm.io/package/bole.md) ^3.0.2
- [terser](https://npm.io/package/terser.md) ^5.14.2
- [cssnano](https://npm.io/package/cssnano.md) ^5.1.7
- [postcss](https://npm.io/package/postcss.md) ^8.2.15
- [minimist](https://npm.io/package/minimist.md) ^1.1.0
- [base64-js](https://npm.io/package/base64-js.md) ^1.5.1
- [cliclopts](https://npm.io/package/cliclopts.md) ^1.1.0
- [html-rewriter-wasm](https://npm.io/package/html-rewriter-wasm.md) ^0.4.1
- [postcss-value-parser](https://npm.io/package/postcss-value-parser.md) ^4.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.8.0 (latest) — 2023-05-22
- 0.7.2 — 2022-07-20
- 0.7.1 — 2022-07-06
- 0.7.0 — 2022-07-01
- 0.6.0 — 2022-03-18
- 0.5.1 — 2015-10-29
- 0.5.0 — 2015-10-28
- 0.4.2 — 2015-10-13
- 0.4.1 — 2015-09-22
- 0.4.0 — 2015-09-01
- 0.3.0 — 2015-03-31
- 0.2.0 — 2015-01-23
- 0.1.6 — 2013-11-04
- 0.1.5 — 2012-07-31
- 0.1.4 — 2012-07-09
- … 3 more at https://npm.io/package/collapsify/versions

## README

# Collapsify [![](http://img.shields.io/npm/dm/collapsify.svg?style=flat)](https://www.npmjs.org/package/collapsify) [![](http://img.shields.io/npm/v/collapsify.svg?style=flat)](https://www.npmjs.org/package/collapsify)

> Inlines all of the JavaScripts, stylesheets, images, fonts etc. of an HTML page.

## Installation

```sh
npm install -g collapsify
```

## Usage

You can use the collapsify CLI like this to download and save the page into a single file like this:
```sh
collapsify -o single-page.html https://my-site.com/
```
see `collapsify -h` for all options.

## API

```javascript
import {simpleCollapsify} from 'collapsify';

await simpleCollapsify('https://example.com', {
  headers: {
    'accept-language': 'en-US'
  }
})
  .then(page => console.log(page))
  .catch(err => console.error(err));

```

The `simpleCollapsify` function takes the URL to collapse, as well as an object of options, and returns a promise that resolves to a String.

### Options

* **headers**: An object of headers, to be added to each HTTP request.
* **forbidden**: A regex that matches blacklisted resources that should be avoided while navigating.

## Requirements
The simple mode and CLI require nodejs >= 18, as they use the global `fetch` function.

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