From 5e22c0a727a8fcb589d155778d9c91f3c5f9c16b Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Mon, 16 Jun 2025 23:16:50 +0200 Subject: [PATCH 1/3] [Tablegen] Make sure prefetches appear before styles --- Libraries/Tablegen/Source/Tablegen.cpp | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Libraries/Tablegen/Source/Tablegen.cpp b/Libraries/Tablegen/Source/Tablegen.cpp index a7a0f6b..56a4872 100644 --- a/Libraries/Tablegen/Source/Tablegen.cpp +++ b/Libraries/Tablegen/Source/Tablegen.cpp @@ -136,6 +136,9 @@ namespace Tablegen pugi::xml_node comment = table.append_child(pugi::node_comment); comment.set_value(" Autogenerated by Tablegen, please avoid editing manually. "); + pugi::xml_node prefetch = table.append_child("div"); + prefetch.append_attribute("hidden"); + pugi::xml_node script = table.append_child("script"); pugi::xml_node styles = table.append_child("style"); @@ -152,9 +155,24 @@ namespace Tablegen pugi::xml_node tableBody = table.append_child("tbody"); for (pugi::xml_node row; const auto& [i, character] : vw::enumerate(characters)) { + std::string imagePath = std::vformat( + settings.ImageFormat, std::make_format_args(character.ImagePath) + ); + std::string animationPath = std::vformat( + settings.AnimationFormat, std::make_format_args(character.AnimationPath) + ); + //////////////////////////////////////////////////////////////////// // HTML //////////////////////////////////////////////////////////////////// + pugi::xml_node prefetchImage = prefetch.append_child("link"); + prefetchImage.append_attribute("rel") = "prefetch"; + prefetchImage.append_attribute("href") = imagePath; + + pugi::xml_node prefetchAnimation = prefetch.append_child("link"); + prefetchAnimation.append_attribute("rel") = "prefetch"; + prefetchAnimation.append_attribute("href") = animationPath; + if (i % settings.CharactersPerRow == 0) { row = tableBody.append_child("tr"); row.append_attribute("class") = "kanji-table-row"; @@ -178,21 +196,6 @@ namespace Tablegen imageWrap.append_attribute("class") = "kanji-image-wrap"; imageWrap.append_attribute("id") = std::format("kanji-{}", i); - std::string imagePath = std::vformat( - settings.ImageFormat, std::make_format_args(character.ImagePath) - ); - std::string animationPath = std::vformat( - settings.AnimationFormat, std::make_format_args(character.AnimationPath) - ); - - pugi::xml_node prefetchImage = container.append_child("link"); - prefetchImage.append_attribute("rel") = "prefetch"; - prefetchImage.append_attribute("href") = imagePath; - - pugi::xml_node prefetchAnimation = container.append_child("link"); - prefetchAnimation.append_attribute("rel") = "prefetch"; - prefetchAnimation.append_attribute("href") = animationPath; - pugi::xml_node image = imageWrap.append_child("input"); image.append_attribute("type") = "checkbox"; image.append_attribute("class") = "kanji-image"; From c7d2d481c851ac0bda6799bb8f39e8b5912a4f84 Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Mon, 16 Jun 2025 23:25:16 +0200 Subject: [PATCH 2/3] [Tablegen] Actually hide the div --- Libraries/Tablegen/Source/Tablegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Tablegen/Source/Tablegen.cpp b/Libraries/Tablegen/Source/Tablegen.cpp index 56a4872..2f6bc25 100644 --- a/Libraries/Tablegen/Source/Tablegen.cpp +++ b/Libraries/Tablegen/Source/Tablegen.cpp @@ -137,7 +137,7 @@ namespace Tablegen comment.set_value(" Autogenerated by Tablegen, please avoid editing manually. "); pugi::xml_node prefetch = table.append_child("div"); - prefetch.append_attribute("hidden"); + prefetch.append_attribute("hidden") = "hidden"; pugi::xml_node script = table.append_child("script"); pugi::xml_node styles = table.append_child("style"); From e1e649975208170c7cee04a6b390f3f15de43061 Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Mon, 16 Jun 2025 23:35:24 +0200 Subject: [PATCH 3/3] [Tablegen] Force preloading --- Libraries/Tablegen/Source/Tablegen.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Libraries/Tablegen/Source/Tablegen.cpp b/Libraries/Tablegen/Source/Tablegen.cpp index 2f6bc25..6b3084d 100644 --- a/Libraries/Tablegen/Source/Tablegen.cpp +++ b/Libraries/Tablegen/Source/Tablegen.cpp @@ -136,8 +136,8 @@ namespace Tablegen pugi::xml_node comment = table.append_child(pugi::node_comment); comment.set_value(" Autogenerated by Tablegen, please avoid editing manually. "); - pugi::xml_node prefetch = table.append_child("div"); - prefetch.append_attribute("hidden") = "hidden"; + pugi::xml_node preload = table.append_child("div"); + preload.append_attribute("hidden") = "hidden"; pugi::xml_node script = table.append_child("script"); pugi::xml_node styles = table.append_child("style"); @@ -165,13 +165,15 @@ namespace Tablegen //////////////////////////////////////////////////////////////////// // HTML //////////////////////////////////////////////////////////////////// - pugi::xml_node prefetchImage = prefetch.append_child("link"); - prefetchImage.append_attribute("rel") = "prefetch"; - prefetchImage.append_attribute("href") = imagePath; + pugi::xml_node preloadImage = preload.append_child("link"); + preloadImage.append_attribute("rel") = "preload"; + preloadImage.append_attribute("href") = imagePath; + preloadImage.append_attribute("as") = "image"; - pugi::xml_node prefetchAnimation = prefetch.append_child("link"); - prefetchAnimation.append_attribute("rel") = "prefetch"; - prefetchAnimation.append_attribute("href") = animationPath; + pugi::xml_node preloadAnimation = preload.append_child("link"); + preloadAnimation.append_attribute("rel") = "preload"; + preloadAnimation.append_attribute("href") = animationPath; + preloadAnimation.append_attribute("as") = "image"; if (i % settings.CharactersPerRow == 0) { row = tableBody.append_child("tr");