Reduce website loading times and related code cleanup

This commit is contained in:
Keavon Chambers
2025-01-08 18:29:54 -08:00
parent 93a60daa24
commit 68e6bec9b5
22 changed files with 112 additions and 56 deletions
-18
View File
@@ -1,18 +0,0 @@
.balance-text {
visibility: hidden;
}
@media (scripting: none) {
.balance-text {
visibility: visible !important;
}
}
@supports (text-wrap: balance) {
.balance-text,
.balanced-text {
text-align: left;
text-wrap: balance;
visibility: visible;
}
}
+11 -1
View File
@@ -124,6 +124,16 @@ function slideTo(carousel, index, smooth) {
carousel.descriptions[index].classList.add("active");
}
// Account for the first image being the faded out last image
const offsetIndex = index + 1;
const slideImages = Array.from(carousel.carouselContainer.querySelectorAll("[data-carousel-slide] [data-carousel-image]"));
// Remove lazy loading from the adjacent images
slideImages[clamp(offsetIndex - 2, 0, slideImages.length - 1)].removeAttribute("loading");
slideImages[clamp(offsetIndex - 1, 0, slideImages.length - 1)].removeAttribute("loading");
slideImages[clamp(offsetIndex, 0, slideImages.length - 1)].removeAttribute("loading");
slideImages[clamp(offsetIndex + 1, 0, slideImages.length - 1)].removeAttribute("loading");
slideImages[clamp(offsetIndex + 2, 0, slideImages.length - 1)].removeAttribute("loading");
setCurrentTransform(carousel, index * -100, "%", smooth);
}
@@ -283,6 +293,6 @@ function dragMove(event) {
}
function clamp(value, min, max) {
const m = Math; // Keep this line, it fixes a bug in Zola's minifier
const m = Math; // This is a workaround for a bug in Zola's minifier
return m.min(m.max(value, min), max);
}