From c50258c47620c845b4df38eb278de1bed5cda69a Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 5 May 2026 16:05:51 +0200 Subject: [PATCH] perf: optimize page load with async HTMX fragments --- templates/anime.gohtml | 84 ++++++++++++++++++-------- templates/components/anime_card.gohtml | 5 +- templates/discover.gohtml | 58 ++++++++++++------ templates/index.gohtml | 58 +++++++++++++----- 4 files changed, 142 insertions(+), 63 deletions(-) diff --git a/templates/anime.gohtml b/templates/anime.gohtml index d8acf85..7043f42 100644 --- a/templates/anime.gohtml +++ b/templates/anime.gohtml @@ -1,3 +1,43 @@ +{{define "anime_characters"}} +
+

Characters & Cast

+
+ {{range (slice . 0 (min (len .) 10))}} +
+
+ {{.Character.Name}} +
+
+ {{.Character.Name}} + {{.Role}} + {{if .VoiceActors}} + {{(index .VoiceActors 0).Person.Name}} + {{end}} +
+
+ {{end}} +
+
+{{end}} + +{{define "anime_recommendations"}} +{{if .}} +
+

Recommendations

+
+ {{range (slice . 0 (min (len .) 8))}} + +
+ {{.Entry.Title}} +
+ {{.Entry.Title}} +
+ {{end}} +
+
+{{end}} +{{end}} + {{define "title"}}{{.Anime.DisplayTitle}}{{end}} {{define "content"}} {{if .WatchlistIDs}}{{end}} @@ -201,27 +241,22 @@ - {{if .Characters}} +

Characters & Cast

-
- {{range (slice .Characters 0 (min (len .Characters) 10))}} -
-
- {{.Character.Name}} -
-
- {{.Character.Name}} - {{.Role}} - {{if .VoiceActors}} - {{(index .VoiceActors 0).Person.Name}} - {{end}} +
+ {{range (seq 5)}} +
+
+
+
+
{{end}}
- {{end}} +
@@ -232,20 +267,19 @@
- {{if .Recommendations}} -
+
+

Recommendations

-
- {{range (slice .Recommendations 0 (min (len .Recommendations) 8))}} - -
- {{.Entry.Title}} -
- {{.Entry.Title}} -
+
+ {{range (seq 8)}} +
+
+
+
{{end}}
- {{end}} +
+ {{end}} diff --git a/templates/components/anime_card.gohtml b/templates/components/anime_card.gohtml index 2780d10..c1b2deb 100644 --- a/templates/components/anime_card.gohtml +++ b/templates/components/anime_card.gohtml @@ -14,10 +14,7 @@ {{$imageUrl = $anime.Images.Jpg.LargeImageURL}} {{end}} -{{$displayTitle := $anime.Title}} -{{if $anime.TitleEnglish}} - {{$displayTitle = $anime.TitleEnglish}} -{{end}} +{{$displayTitle := $anime.DisplayTitle}}
diff --git a/templates/discover.gohtml b/templates/discover.gohtml index f04d952..4b75fcb 100644 --- a/templates/discover.gohtml +++ b/templates/discover.gohtml @@ -1,6 +1,5 @@ {{define "title"}}Discover{{end}} {{define "content"}} -{{if .WatchlistIDs}}{{end}} {{end}} - -
- {{range .CurrentlyAiring}} - {{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}} - {{end}} +
+ {{template "catalog_skeleton"}}
@@ -30,12 +26,46 @@
- -
- {{range .MostPopular}} - {{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}} - {{end}} +
+ {{template "catalog_skeleton"}}
-{{end}} \ No newline at end of file + + +{{end}} + +{{define "catalog_section"}} + {{if eq .Section "Continue"}} + {{if .ContinueWatching}} + {{template "continue_watching" .ContinueWatching}} + {{end}} + {{else}} +
+ {{range .Animes}} + {{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}} + {{end}} +
+ {{end}} +{{end}} + +{{define "catalog_skeleton"}} +
+ {{range (seq 6)}} +
+
+
+
+ {{end}} +
+{{end}}