Registry / devops / grunt-minify-html

grunt-minify-html

JSON →
library3.0.0jsnpmunverified

Minify HTML files using the minimize library, which uses a proper HTML parser instead of fragile regexes like other minifiers. Version 3.0.0 is the latest stable release, last updated in 2016. It requires Grunt >=0.4.0 and Node >=4. Differentiates from grunt-contrib-htmlmin by using a robust parser for more accurate minification and fewer errors.

npm install grunt-minify-html
INSTALL
IMPORT
SIG · GRUNT-MINIFY-HTML
G
grunt-minify-html
devopsjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

minifyHtml
// In Gruntfile.js, use grunt.loadNpmTasks('grunt-minify-html') or load-grunt-tasks
require('grunt-minify-html') directly
This is a Grunt plugin, not a regular module. Load via Grunt's task loading mechanism.
minimize options
options: { cdata: true, comments: false, condense: true }
options: { removeComments: true }
Options are passed to the minimize library. See minimize docs for available options.

Shows how to configure the Grunt task to minify an HTML file from src to dist.

// Install: npm install --save-dev grunt-minify-html // Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-minify-html'); grunt.initConfig({ minifyHtml: { options: { cdata: true }, dist: { files: { 'dist/index.html': 'src/index.html' } } } }); grunt.registerTask('default', ['minifyHtml']); };
Debug
Known issues
deprecatedPackage has been deprecated and is no longer maintained. It relies on minimize library which has known issues and outdated dependencies.
fix
Migrate to grunt-contrib-htmlmin or use a modern build tool like webpack with html-loader or html-minifier-terser.
affects: >=3.0.0
gotchaminimize parser may not handle all HTML5 elements correctly, leading to broken output in edge cases.
fix
Test minified output thoroughly, especially with complex HTML5 structures.
affects: *
breakingVersion 3.0.0 removed support for Node <4
fix
Ensure Node.js version is >=4 for v3. Use older versions for legacy Node.
affects: >=3.0.0
Errors
Common errors & fixes
Warning: Task "minifyHtml" not found. Use --force to continue.
Grunt plugin not loaded correctly in Gruntfile.
fix
Add grunt.loadNpmTasks('grunt-minify-html'); to your Gruntfile.
Fatal error: Cannot find module 'grunt-minify-html'
Package not installed or not in node_modules.
fix
Run npm install --save-dev grunt-minify-html in your project directory.
TypeError: Cannot set property 'minifyHtml' of undefined
Gruntfile missing grunt.initConfig() or improper structure.
fix
Ensure the Gruntfile exports a function that calls grunt.initConfig with the minifyHtml task config.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
gruntrequiredPeer dependency required to run the Grunt plugin
Agent activity
4 hits · last 30 days
node
4
Resources
grunt-minify-html — npm install grunt-minify-html · libregistry