html-minifier
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
camel-case | 3.0.0 | 1.6 kB | MIT | prod | |
clean-css | 4.0.13 | 77.48 kB | MIT | prod | 1 |
commander | 2.9.0 | 13.11 kB | MIT | prod | |
he | 1.1.1 | 33.39 kB | MIT | prod | |
ncname | 1.0.0 | 878 B | MIT | prod | |
param-case | 2.1.1 | 1.93 kB | MIT | prod | |
relateurl | 0.2.7 | 9.49 kB | MIT | prod | |
uglify-js | 2.8.29 | 127.25 kB | BSD-2-Clause | prod | 1 1 |
HTML-minifier is a highly configurable, well-tested, JavaScript-based HTML minifier. It serves the primary function of reducing the size of your HTML files by eliminating unnecessary white spaces, comments, and other non-required elements. This reduction in size leads to faster load times and improved performance for your websites, which is beneficial for both user experience and SEO rankings.
To use html-minifier, you can install it via npm for command line application or programmatic use. Here is an example of how to install it:
# for command line use
npm install html-minifier -g
# for programmatic use
npm install html-minifier
Also, you can clone it via Git:
git clone git://github.com/kangax/html-minifier.git
cd html-minifier
npm link .
You can activate html-minifier options when running the command. Here is an example of a sample command line:
html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true
For Node.js usage, see the following example:
var minify = require('html-minifier').minify;
var result = minify('<p title="blah" id="moo">foo</p>', {
removeAttributeQuotes: true
});
// output: '<p title=blah id=moo>foo</p>'
For detailed documentation on how to use html-minifier, options, testing results, and more, you can refer to its official GitHub page: https://github.com/kangax/html-minifier. Moreover, there is a corresponding blog post here which provides comprehensive information about the tool's working mechanism, option descriptions, and other aspects.