Minify HTML

Minify the HTML code of your pages.

Options

extensions object
Default:
[ ".html" ]
options object
Default:
{
  do_not_minify_doctype: true,
  ensure_spec_compliant_unquoted_attribute_values: true,
  keep_closing_tags: false,
  keep_html_and_head_opening_tags: false,
  keep_spaces_between_attributes: true,
  keep_comments: false,
  remove_bangs: false,
  remove_processing_instructions: false
}

Description

The MinifyHTML plugin minifies the HTML code of your pages using the minify-html minifier. It can also minify CSS and JavaScript code.

Installation

Import this plugin in your _config.ts file to use it:

import lume from "lume/mod.ts";
import minifyHTML from "lume/plugins/minify_html.ts";

const site = lume();

site.use(minifyHTML(/* Options */));

export default site;

Configuration

This plugin accepts a configuration object. The available options are:

  • extensions: An array with the extensions of the files that will be minified. By default it is [".html"].
  • options: An object with the available options for minify-html.

If you need to minify CSS and / or JS files, it's recommended that you use plugins specifically for those instead, like LightningCSS and Terser respectively.