@sardine/eleventy-plugin-tinyhtml

A plugin for 11ty to minify and optimise HTML

Usage no npm install needed!

<script type="module">
  import sardineEleventyPluginTinyhtml from 'https://cdn.skypack.dev/@sardine/eleventy-plugin-tinyhtml';
</script>

README

eleventy-plugin-tinyHTML

An 11ty plugin to optimise HTML.

Features

Requirements

Installation

npm install --save-dev @sardine/eleventy-plugin-tinyhtml

How to use it

const tinyHTML = require('@sardine/eleventy-plugin-tinyhtml');
module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(tinyHTML);
};

Configuration

const tinyHTML = require('@sardine/eleventy-plugin-tinyhtml');
module.exports = function (eleventyConfig) {
  const tinyHTMLOptions = {
    html5: true,
    removeRedundantAttributes : true,
  };

  eleventyConfig.addPlugin(tinyHTML, tinyHTMLOptions);
};

html-minifier options

By default the following options are used:

{
  collapseBooleanAttributes: true,
  collapseWhitespace: true,
  decodeEntities: true,
  html5: true,
  removeAttributeQuotes: true,
  removeComments: true,
  removeOptionalTags: true,
  sortAttributes: true,
  sortClassName: true,
};

License

MIT