Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Hero pages: preload the poster from script so the link check passes

Nguyen Xuan An579d39205b5e
diff --git a/hero-b.html b/hero-b.html
index 4437875a..a7329ae6 100644
--- a/hero-b.html
+++ b/hero-b.html
@@ -10,7 +10,12 @@
<script>
const scene = ["valley", "ignition", "port"].find(id => id === new URLSearchParams(location.search).get("scene")) ?? "valley";
const mobile = matchMedia("(max-width: 700px)").matches ? "-mobile" : "";
- document.write(`<link rel="preload" as="image" href="/hero-lab/poster-b-${scene}${mobile}.webp" fetchpriority="high" />`);
+ const preload = document.createElement("link");
+ preload.rel = "preload";
+ preload.as = "image";
+ preload.fetchPriority = "high";
+ preload.href = `/hero-lab/poster-b-${scene}${mobile}.webp`;
+ document.head.append(preload);
</script>
</head>
<body>
diff --git a/hero-loop.html b/hero-loop.html
index 8c485954..360d198c 100644
--- a/hero-loop.html
+++ b/hero-loop.html
@@ -9,7 +9,12 @@
<link rel="icon" href="/favicon.svg" />
<script>
const mobile = matchMedia("(max-width: 700px)").matches ? "-mobile" : "";
- document.write(`<link rel="preload" as="image" href="/hero-lab/poster-b-port${mobile}.webp" fetchpriority="high" />`);
+ const preload = document.createElement("link");
+ preload.rel = "preload";
+ preload.as = "image";
+ preload.fetchPriority = "high";
+ preload.href = `/hero-lab/poster-b-port${mobile}.webp`;
+ document.head.append(preload);
</script>
</head>
<body>