|
2610 | 2610 | waitForHeroVideo(() => { |
2611 | 2611 | console.log('🎬 Hero video loaded! Starting to load other videos...'); |
2612 | 2612 |
|
| 2613 | + // Restore frameVideo immediately when hero video is loaded (it's in viewport) |
| 2614 | + const frameVideo = document.getElementById('frameVideo'); |
| 2615 | + if (frameVideo) { |
| 2616 | + if (frameVideo.hasAttribute('data-temp-src') && !frameVideo.src) { |
| 2617 | + frameVideo.src = frameVideo.getAttribute('data-temp-src'); |
| 2618 | + frameVideo.removeAttribute('data-temp-src'); |
| 2619 | + frameVideo.load(); |
| 2620 | + } |
| 2621 | + const frameSource = frameVideo.querySelector('source'); |
| 2622 | + if (frameSource && frameSource.hasAttribute('data-temp-src') && !frameSource.src) { |
| 2623 | + frameSource.src = frameSource.getAttribute('data-temp-src'); |
| 2624 | + frameSource.removeAttribute('data-temp-src'); |
| 2625 | + frameVideo.load(); |
| 2626 | + } |
| 2627 | + } |
| 2628 | + |
2613 | 2629 | // Set up smart Intersection Observer for optimized loading |
2614 | 2630 | const videoObserver = new IntersectionObserver((entries) => { |
2615 | 2631 | entries.forEach(entry => { |
|
2631 | 2647 | if (video.hasAttribute('data-temp-src') && !video.src) { |
2632 | 2648 | video.src = video.getAttribute('data-temp-src'); |
2633 | 2649 | video.removeAttribute('data-temp-src'); |
| 2650 | + video.load(); |
2634 | 2651 | } |
2635 | 2652 | const source = video.querySelector('source'); |
2636 | 2653 | if (source && source.hasAttribute('data-temp-src') && !source.src) { |
2637 | 2654 | source.src = source.getAttribute('data-temp-src'); |
2638 | 2655 | source.removeAttribute('data-temp-src'); |
| 2656 | + video.load(); |
2639 | 2657 | } |
2640 | 2658 |
|
2641 | 2659 | // Change preload from "none" to appropriate value |
|
2689 | 2707 | }); |
2690 | 2708 |
|
2691 | 2709 | // Observe all videos except hero videos (after delay) |
| 2710 | + // Also ensure frameVideo is observed and loaded immediately since it's critical |
2692 | 2711 | document.querySelectorAll('video').forEach(video => { |
2693 | 2712 | // Skip hero videos - they're already loading with high priority |
2694 | 2713 | if (video.id !== 'hero-video-main' && video.id !== 'hero-video-mobile') { |
2695 | 2714 | videoObserver.observe(video); |
| 2715 | + |
| 2716 | + // If it's frameVideo, ensure it's loaded immediately (it's in viewport) |
| 2717 | + if (video.id === 'frameVideo') { |
| 2718 | + // Restore src if it was blocked |
| 2719 | + if (video.hasAttribute('data-temp-src') && !video.src) { |
| 2720 | + video.src = video.getAttribute('data-temp-src'); |
| 2721 | + video.removeAttribute('data-temp-src'); |
| 2722 | + video.load(); |
| 2723 | + } |
| 2724 | + const source = video.querySelector('source'); |
| 2725 | + if (source && source.hasAttribute('data-temp-src') && !source.src) { |
| 2726 | + source.src = source.getAttribute('data-temp-src'); |
| 2727 | + source.removeAttribute('data-temp-src'); |
| 2728 | + video.load(); |
| 2729 | + } |
| 2730 | + } |
2696 | 2731 | } |
2697 | 2732 | }); |
2698 | 2733 |
|
|
0 commit comments