🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

htmlmin

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlmin

A simple HTML minifier

0.0.7
latest
Source
npm
Version published
Weekly downloads
758
-49.37%
Maintainers
1
Weekly downloads
 
Created
Source

Description

A simple html minifier.

idea and html parser from https://github.com/kangax/html-minifier

Installation

npm -g install htmlmin

Test

npm -g install mocha
mocha

Usage

The module exports the htmlmin function, so you can use it with :

var htmlmin = require('htmlmin');

The function htmlmin takes two arguments :

  • input : the html content you want to minimize.
  • options : minimize options.

options

  • cssmin: true, minifier inline css
  • jsmin: true, minifier inline javascript
  • caseSensitive: true
  • removeComments: true, remove comment, if you want keep comment, give a '!' at the beigin of your comment
  • removeIgnored: false, remove tags not recognize
  • removeOptionalTags: false, some tag can without end tag, remove these end tags
  • collapseWhitespace: false,

Example :

var htmlmin = require('htmlmin');
var html = '<script type=\"text\/javascript\">var abc= \"hello\";<\/script>\r\n\r\n\r\n' +
            '<style type=\"text\/css\">#foo { color: red;        }          <\/style>\r\n\r\n\r\n' +
            '<div>\r\n  <div>\r\n    <div><!-- hello -->\r\n      <div>' +
            '<!--! hello -->\r\n        <div>\r\n          <div class=\"\">\r\n\r\n            ' +
            '<textarea disabled=\"disabled\">     this is a textarea <\/textarea>\r\n          ' +
            '<\/div>\r\n        <\/div>\r\n      <\/div>\r\n    <\/div>\r\n  <\/div>\r\n<\/div>' +
            '<pre>       \r\nxxxx<\/pre><span>x<\/span> <span>Hello<\/span> <b>billy<\/b>     \r\n' +
            '<input type=\"text\">\r\n<textarea><\/textarea>\r\n<pre><\/pre>';

console.log(htmlmin(html))

this will output :

<script>var abc="hello"</script><style>#foo{color:red}</style><div><div><div><div><!--! hello --><div><div><textarea disabled>     this is a textarea </textarea></div></div></div></div></div></div><pre>       
xxxx</pre><span>x</span><span>Hello</span><b>billy</b><input><textarea></textarea><pre></pre></b></span>
</pre></div></style></script>

License

MIT

FAQs

Package last updated on 10 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts