Hime can minify HTML, CSS, and JavaScript inside template using tdewolff/minify
package main import ( "log" "github.com/moonrhythm/hime" ) func main() { app := hime.New() t := app.Template() t.Minify() t.Parse("index", ` <!doctype html> <html> <head> <title>Hime</title> <style> h1 { color: blue; } </style> </head> <body> <h1>Hello, {{.Name}}</h1> <script> alert('Hello, {{.Name}}') </script> </body> </html> `) app.Handler(hime.Handler(index)) app.Address(":8080") err := app.ListenAndServe() if err != nil { log.Fatal(err) } } func index(ctx *hime.Context) error { return ctx.View("index", map[string]any{ "Name": "Hime", }) }
Output
<!doctype html><title>Hime</title><style>h1{color:blue}</style><h1>Hello, Hime</h1><script>alert('Hello, Hime')</script>
To control which minifiers are used, call t.MinifyWith with a hime.TemplateMinifyConfig instead of t.Minify().
t.MinifyWith
hime.TemplateMinifyConfig
t.Minify()
There was an error while loading. Please reload this page.