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-4/

Inline Asset Minifier

Build a helper that takes an HTML string and produces an equivalent string where inline CSS and JavaScript are minified, while safely skipping templating placeholders and non-JS scripts that should remain readable.

Capabilities

Minify inline styles

  • Collapses CSS inside style attributes and <style> tags, trimming redundant whitespace and semicolons without changing meaning. @test

Minify inline scripts

  • Minifies JavaScript inside event handler attributes and <script> blocks meant for the browser, preserving behavior. @test

Respect template fragments

  • Leaves templating placeholders (e.g., {{token}}, <% code %>) untouched while minifying surrounding CSS/JS. @test

Skip non-JS script types

  • Leaves script blocks with non-JS MIME types (e.g., application/ld+json) unchanged while minifying supported scripts. @test

Implementation

@generates

API

/**
 * Minifies inline CSS and JavaScript inside an HTML string.
 * @param {string} html - The HTML to process.
 * @param {{ templateFragments?: RegExp[]; skipScriptTypes?: string[] }} [options]
 * @returns {string} Minified HTML with preserved templating fragments and skipped scripts.
 */
export function minifyInlineAssets(html, options = {}) {}

Dependencies { .dependencies }

html-minifier { .dependency }

Provides HTML, inline CSS, and inline JS minification.

Install with Tessl CLI

npx tessl i tessl/npm-html-minifier

tile.json