fastify/point-of-view

support for async minify methods

quiquelhappy opened this issue ยท 3 comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

๐Ÿš€ Feature Proposal

Add support for async minify methods.

html-minifier-terser uses exactly the same call type, so it would be as easy as executing the exact same call this library is already using, but with an await right before it

I would do a PR myself, but when I saw the codebase and the amount of calls to the minify method everywhere, I felt kinda overwelmed mostly because none of them are inside an async method. If someone who better knows this lib could just add async where needed and await the minify method, it'd be enough to add support for this alternative

I would consider this change to be quite important and something to do in the near future, since with time, new vulnerabilities for html-minify will rise, and it's been unmantained for 4 years now

Motivation

The mentioned html-minifiier lib mentioned in the docs is now long unmantained and shouldn't be used.

html-minifier-terser seems like a good performant options which uses the same option settings.

Example

html-minifier-terser:

export function minify(value: string, options?: Options): Promise<string>;

currently used method call, html-minifier

export function minify(text: string, options?: Options): string;

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

I saw both projects.
I think the terser version is a fork since they share same readme and same options :)
tried to help you @quiquelhappy with a PR: #378

@quiquelhappy release 9.0 use minifier-terser.
Can you consider this issue closed?