https://github.com/halo-lab/eleventy-plugin-compress
Compresses HTML and assets (CSS, JavaScript) that are referenced from it with brotli, gzip and deflate algorithms.
https://github.com/halo-lab/eleventy-plugin-compress
brotli compression deflate eleventy gzip
Last synced: 8 days ago
JSON representation
Compresses HTML and assets (CSS, JavaScript) that are referenced from it with brotli, gzip and deflate algorithms.
- Host: GitHub
- URL: https://github.com/halo-lab/eleventy-plugin-compress
- Owner: Halo-Lab
- License: isc
- Archived: true
- Created: 2021-04-06T06:48:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T07:36:03.000Z (over 3 years ago)
- Last Synced: 2024-11-24T00:50:00.510Z (11 months ago)
- Topics: brotli, compression, deflate, eleventy, gzip
- Language: TypeScript
- Homepage:
- Size: 54.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eleventy-plugin-compress 👜
**⚠️ This code moves to [the new location](https://github.com/Halo-Lab/eleventy-packages). Please, refer there to get a new development status.**
[](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;
}
```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! ✌️