# eleventy-plugin-compress

> Plugin for compressing HTML, CSS and JavaScript from templates with brotli/gzip/deflate algorithms.

Latest version **1.0.5** (published 2023-01-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install eleventy-plugin-compress
pnpm add eleventy-plugin-compress
yarn add eleventy-plugin-compress
bun add eleventy-plugin-compress
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-01-30 |
| First published | 2021-04-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Kapelianovych Yevhen |
| Maintainers | halolab |
| Keywords | Eleventy, brotli, gzip, deflate, plugin, compression |

## Links

- npm: https://www.npmjs.com/package/eleventy-plugin-compress
- Repository: https://github.com/Halo-Lab/eleventy-plugin-compress
- Homepage: https://github.com/Halo-Lab/eleventy-plugin-compress#readme
- Issues: https://github.com/Halo-Lab/eleventy-plugin-compress/issues
- npm.io page: https://npm.io/package/eleventy-plugin-compress

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2023-01-30
- 1.0.4 — 2022-03-28
- 1.0.2 — 2021-05-19
- 1.0.1 — 2021-04-30
- 1.0.0 — 2021-04-06

## README

# eleventy-plugin-compress 👜

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Compresses HTML and assets (CSS, JavaScript) that are referenced from it with [`brotli`](https://brotli.org), [`gzip`](http://www.gzip.org) and [`deflate`](https://en.wikipedia.org/wiki/Deflate) algorithms.

## Intention

Even big assets(pages, scripts, styles) should be delivered to client quickly. In order to do that, they must be compressed ☝️! ... At least.

## Get started

### Installation

At first run:

```sh
npm i -D eleventy-plugin-compress
```

and eventually add to Eleventy as plugin:

```js
const { compress } = require('eleventy-plugin-compress');

module.exports = (eleventyConfig) => {
	eleventyConfig.addPlugin(compress, {
		/* Optional options. */
	});
};
```

> Important: you should register plugin after any other plugins or [`transform`](https://www.11ty.dev/docs/config/#transforms) functions!

### Options

The plugin can accept following options:

```ts
type CompressAlgorithm = 'brotli' | 'gzip' | 'deflate';

interface CompressPluginOptions {
	/**
	 * Signals whether this plugin should do its job.
	 * By default, it is on in production environment.
	 */
	enabled?: boolean;
	algorithm?: CompressAlgorithm | ReadonlyArray<CompressAlgorithm>;
}
```

You can choose one of some algorithms to compress assets. By default, `brotli` is used.

> For proper work of this plugin, it is assumed that in time of compiling HTML all CSS and JavaScript are already processed and folded into [_output_](https://www.11ty.dev/docs/config/#output-directory) directory.

## Word from author

Have fun! ✌️

<a href="https://www.halo-lab.com/?utm_source=github-brifinator-3000">
  <img src="https://api.halo-lab.com/wp-content/uploads/dev_halo.svg" alt="Developed in Halo lab" height="60">
</a>

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