|
27 | 27 | <link rel="preload" href="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" as="script"> |
28 | 28 | <link rel="preload" href="./static/js/index.js" as="script"> |
29 | 29 |
|
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 --> |
32 | 32 |
|
33 | 33 | <style> |
34 | 34 | /* System font stack - faster loading, no external fonts needed */ |
|
1252 | 1252 | } |
1253 | 1253 | } |
1254 | 1254 |
|
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; |
1262 | 1258 |
|
1263 | | - if (heroVideoMobile) { |
| 1259 | + if (isMobile && heroVideoMobile) { |
| 1260 | + // Mobile device - load mobile version |
1264 | 1261 | heroVideoMobile.setAttribute('fetchpriority', 'high'); |
1265 | | - // Force load immediately - don't wait |
1266 | 1262 | heroVideoMobile.load(); |
1267 | 1263 | 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 | + } |
1268 | 1283 | } |
1269 | 1284 | }; |
1270 | 1285 |
|
|
0 commit comments