From 37a628ad09b1aaa25b5de611566bd2e5fc801c20 Mon Sep 17 00:00:00 2001 From: partisan Date: Thu, 29 Aug 2024 22:48:04 +0200 Subject: [PATCH] added lazy loading to img for blogs --- main.go | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 6fe28d0..cb3350c 100644 --- a/main.go +++ b/main.go @@ -216,6 +216,41 @@ func renderIndex(w http.ResponseWriter) { renderTemplate(w, "index.html", nil) } +// Helper function to add loading="lazy" to all img tags +func injectLazyLoading(htmlContent string) string { + // Split the content by ") + if endOfTag == -1 { + // If no closing bracket is found, add the remaining part as is + modifiedContent += "