eleventy-plugin-compress

1.0.5 • Public • Published

eleventy-plugin-compress 👜

code style: prettier

Compresses HTML and assets (CSS, JavaScript) that are referenced from it with brotli, gzip and 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:

npm i -D eleventy-plugin-compress

and eventually add to Eleventy as plugin:

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 functions!

Options

The plugin can accept following options:

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 directory.

Word from author

Have fun! ✌️

Developed in Halo lab

Dependents (0)

Package Sidebar

Install

npm i eleventy-plugin-compress

Weekly Downloads

46

Version

1.0.5

License

ISC

Unpacked Size

25.9 kB

Total Files

5

Last publish

Collaborators

  • halolab