CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-html-minifier

Highly configurable, well-tested, JavaScript-based HTML minifier with extensive optimization options

86

1.17x
Overview
Eval results
Files

task.mdevals/scenario-5/

Lightweight HTML Pruning

Transforms raw HTML into a lean document or fragment by pruning optional tags and normalizing doctypes for embeddable output.

Capabilities

Normalize doctype

  • Converts any provided HTML doctype to the short HTML5 form <!doctype html> at the top of the output, preserving the remaining markup. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> becomes the short form while keeping content intact. @test

Strip optional wrappers

  • Removes optional structural wrappers such as <html>, <head>, and <body> when they only provide default containers and have no attributes, keeping head resources before body content in the resulting string. @test

Prune empty containers

  • Eliminates empty non-void elements (including whitespace-only nodes) like <div> or <section> when they have no children and no attributes, while preserving empty elements in a keep list (script, style, meta, link, img, br, hr). @test

Avoid auto-generated tags

  • For HTML fragments without top-level <html> or <body> tags, returns a trimmed fragment without inserting default wrappers, while still collapsing redundant whitespace and removing optional closing tags inside the fragment. @test

Implementation

@generates

API

// Accepts raw HTML as a string and returns pruned HTML as a string.
export function pruneMarkup(html);

Dependencies { .dependencies }

html-minifier { .dependency }

Used to perform tag pruning, doctype normalization, and fragment-safe minification.

Install with Tessl CLI

npx tessl i tessl/npm-html-minifier

tile.json