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

htmlnano

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlnano

Modular HTML minifier, built on top of the PostHTML

0.2.5
Source
npm
Version published
Weekly downloads
381K
-2.32%
Maintainers
2
Weekly downloads
 
Created

What is htmlnano?

htmlnano is a highly configurable HTML minifier that helps reduce the size of HTML files by removing unnecessary characters, comments, and whitespace. It also provides various optimization options to improve the performance of web pages.

What are htmlnano's main functionalities?

Minification

This feature removes unnecessary characters, comments, and whitespace from HTML files to reduce their size.

const htmlnano = require('htmlnano');
const html = '<!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <h1>Hello, world!</h1> </body> </html>';
htmlnano.process(html).then(result => console.log(result.html));

Attribute Optimization

This feature removes empty attributes from HTML tags to further reduce the file size.

const htmlnano = require('htmlnano');
const html = '<img src="image.jpg" alt="" />';
const options = { removeEmptyAttributes: true };
htmlnano.process(html, options).then(result => console.log(result.html));

CSS and JS Minification

This feature minifies inline CSS and JavaScript within HTML files to optimize performance.

const htmlnano = require('htmlnano');
const html = '<style>body { margin: 0; }</style><script>console.log("Hello, world!");</script>';
const options = { minifyCss: true, minifyJs: true };
htmlnano.process(html, options).then(result => console.log(result.html));

Removing Redundant Attributes

This feature removes redundant attributes from HTML tags to make the HTML cleaner and smaller.

const htmlnano = require('htmlnano');
const html = '<input type="text" disabled="disabled" />';
const options = { removeRedundantAttributes: true };
htmlnano.process(html, options).then(result => console.log(result.html));

Other packages similar to htmlnano

Keywords

posthtml

FAQs

Package last updated on 09 Nov 2019

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