Skip to content

Commit 1a9c3fb

Browse files
committed
add
1 parent 96f52d6 commit 1a9c3fb

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

index.html

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<link rel="preload" href="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" as="script">
2828
<link rel="preload" href="./static/js/index.js" as="script">
2929

30-
<!-- Preload hero video for faster loading -->
31-
<link rel="preload" href="./resources/head/head_new_firefox_720p.mp4" as="video" type="video/mp4" fetchpriority="high">
30+
<!-- Note: Hero video preload is handled by video element's preload="auto" attribute -->
31+
<!-- Using link rel="preload" would cause duplicate requests -->
3232

3333
<style>
3434
/* System font stack - faster loading, no external fonts needed */
@@ -1252,19 +1252,34 @@
12521252
}
12531253
}
12541254

1255-
// Priority load hero videos immediately
1256-
if (heroVideoMain) {
1257-
heroVideoMain.setAttribute('fetchpriority', 'high');
1258-
// Force load immediately - don't wait
1259-
heroVideoMain.load();
1260-
showHeroVideo(heroVideoMain);
1261-
}
1255+
// Priority load hero videos - only load the one that's visible
1256+
// This prevents loading both desktop and mobile versions simultaneously
1257+
const isMobile = window.innerWidth <= 768 || window.matchMedia('(max-width: 768px)').matches;
12621258

1263-
if (heroVideoMobile) {
1259+
if (isMobile && heroVideoMobile) {
1260+
// Mobile device - load mobile version
12641261
heroVideoMobile.setAttribute('fetchpriority', 'high');
1265-
// Force load immediately - don't wait
12661262
heroVideoMobile.load();
12671263
showHeroVideo(heroVideoMobile);
1264+
// Prevent desktop version from loading
1265+
if (heroVideoMain) {
1266+
heroVideoMain.preload = 'none';
1267+
heroVideoMain.removeAttribute('src');
1268+
const source = heroVideoMain.querySelector('source');
1269+
if (source) source.removeAttribute('src');
1270+
}
1271+
} else if (heroVideoMain) {
1272+
// Desktop device - load desktop version
1273+
heroVideoMain.setAttribute('fetchpriority', 'high');
1274+
heroVideoMain.load();
1275+
showHeroVideo(heroVideoMain);
1276+
// Prevent mobile version from loading
1277+
if (heroVideoMobile) {
1278+
heroVideoMobile.preload = 'none';
1279+
heroVideoMobile.removeAttribute('src');
1280+
const source = heroVideoMobile.querySelector('source');
1281+
if (source) source.removeAttribute('src');
1282+
}
12681283
}
12691284
};
12701285

0 commit comments

Comments
 (0)