HTMLMinifier is a Javascript-based HTML minifier (duh), with lint-like capabilities.
See corresponding blog post for all the gory details of how it works, description of each option, testing results and conclusions.
Test suite is available online.
Installing with npm:
npm install html-minifier
Building distribution:
> cat src/htmlparser.js src/htmlminifier.js src/htmllint.js > dist/all.js
Testing locally:
> npm test