1.0.5 • Published 1 year ago

eleventy-plugin-compress v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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! ✌️