Skip to content

Commit bcf7226

Browse files
committed
Lazy load images
1 parent b46cdac commit bcf7226

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

js/index.js

+24-8
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,27 @@ const handleResize = () => {
448448
});
449449
};
450450

451-
// Preload images, initialize smooth scrolling, apply scroll-triggered animations, and remove loading class from body
452-
preloadImages(".grid__item-inner").then(() => {
453-
initSmoothScrolling();
454-
initIntroAnimation();
455-
handleResize(); // Add the resize handler
456-
scroll();
457-
document.body.classList.remove("loading");
458-
});
451+
const sequentialImageLoading = () => {
452+
// First phase: Load only intro and precording section images
453+
const prioritySelector =
454+
".section--intro .grid__item-inner, .section--precording .grid__item-inner";
455+
456+
preloadImages(prioritySelector).then(() => {
457+
initSmoothScrolling();
458+
initIntroAnimation();
459+
handleResize();
460+
scroll();
461+
462+
// Remove loading class to show initial content
463+
document.body.classList.remove("loading");
464+
465+
// Second phase: After high-priority sections are shown, start loading the rest
466+
setTimeout(() => {
467+
const remainingImagesSelector =
468+
".section:not(.section--intro):not(.section--precording) .grid__item-inner";
469+
preloadImages(remainingImagesSelector);
470+
}, 100); // Small delay to prioritize rendering the visible content first
471+
});
472+
};
473+
474+
sequentialImageLoading();

0 commit comments

Comments
 (0)