Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexwkleung/simple-html-minifier-terser

A utility to minify HTML using html-minifier-terser with predefined options
https://github.com/alexwkleung/simple-html-minifier-terser

html-minifier html-minifier-terser utilities utility wrapper-functions

Last synced: about 1 month ago
JSON representation

A utility to minify HTML using html-minifier-terser with predefined options

Awesome Lists containing this project

README

        

# simple-html-minifier-terser

A utility to minify HTML using [html-minifier-terser](https://github.com/terser/html-minifier-terser) with predefined options.

Minifying HTML using html-minifier-terser requires setup by default. While some may prefer to manually setup html-minifier-terser, some just want a simple zero-config HTML minifier that just works. Therefore, those who are in the latter, including myself, will prefer using simple-html-minifier-terser for their needs.

This is ESM-only.

# Installation

Install via npm, directly from the repository.

```bash
npm install https://github.com/alexwkleung/simple-html-minifier-terser
```

# Example Usage

`minifyHtml` function returns a promise, therefore you need to resolve it.

Here is a basic example:

```typescript
async function f(): Promise {
let template: string = `






foo


foo



`;

return Promise.resolve(minifyHtml(template)).then((minifiedCallbackData) => {
console.log(minifiedCallbackData);
});
}
```

# License

[MIT License.](https://github.com/alexwkleung/simple-html-minifier-terser/blob/main/LICENSE)