Minify HTML

Minify the HTML code of your pages.

Options See on deno.land

extensions object

The list of extensions this plugin applies to.

Default:
[ ".html" ]
options object

Default options for minify-html library

do_not_minify_doctype boolean

Do not minify DOCTYPEs. Minified DOCTYPEs may not be spec compliant.

Default:
true
ensure_spec_compliant_unquoted_attribute_values boolean

Ensure all unquoted attribute values in the output do not contain any characters prohibited by the WHATWG specification.

Default:
true
keep_closing_tags boolean

Do not omit closing tags when possible.

Default:
false
keep_html_and_head_opening_tags boolean

Do not omit <html> and <head> opening tags when they don't have attributes.

Default:
false
keep_spaces_between_attributes boolean

Keep spaces between attributes when possible to conform to HTML standards.

Default:
false
keep_comments boolean

Keep all comments.

Default:
false
keep_ssi_comments boolean

Keep SSI comments.

preserve_brace_template_syntax boolean

When {{, {#, or {% are seen in content, all source code until the subsequent matching closing }}, #}, or %} respectively gets piped through untouched.

preserve_chevron_percent_template_syntax boolean

When <% is seen in content, all source code until the subsequent matching closing %> gets piped through untouched.

minify_js boolean

If enabled, content in <script> tags with a JS or no MIME type will be minified using minify-js.

Default:
true
minify_css boolean

If enabled, CSS in <style> tags and style attributes will be minified.

Default:
true
remove_bangs boolean

Remove all bangs.

Default:
false
remove_processing_instructions boolean

Remove all processing_instructions.

Default:
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: Array with the extensions of the files that will be minified. By default it is [".html"], but you can include also .css and .js to minify these files.
  • options: The available options for minify-html. See the documentation for more info.