Open charnould opened 1 year ago
Hi @charnould
We could create a "Minify Middleware". I believe this middleware may resolve most of your problems.
The challenging aspect is that it needs to detect the proper minify algorithm based on the content-type such as HTML, JavaScript, CSS, and others.
@yusukebe i also plan to use hono for my own website. A minify middleware would also help me a lot, especially for the html templates. Do you plan to include this middleware? Is it possible to wait for it?
Hi @niklasgrewe !
I have an idea to implement a minify middleware and I'll try it later, may be soon!
@yusukebe awesome, thank you very much for your effort on this project, it's clean, simple and powerful 👍 One question for clarification: are template literals more efficient/faster than the jsx
middleware? to be honest, sometimes I don't know where the differences or the advantages and disadvantages are...
I understand that it may be challenging to implement it for all requests. In the meantime, you can simply do it on a per-handler basis.
import * as minifyHtml from '@minify-html/node'
app.get('/compress, async (c) => {
return c.html(minifyHtml.minify(Buffer.from(html`...`), {}).toString())
})
It would be cool if c.html() accepts also Buffer.
Context
Hono
is about performance.For example:
Use case
c.html()
+ template literals for this.(If I get it, it's more efficient/faster than
JSX
middleware).Prettier
to format my code and thus my template literals.Prettier
applies are sent over the wire.Consequently, my source-code looks like this (see below)
html
-minified It would weight - in my case - around 30% lessKB
.Hence: more speed, less outgress...
Questions
hono
offers this feature?