Skip to content

Commit

Permalink
Testing fetch priority
Browse files Browse the repository at this point in the history
  • Loading branch information
cmegalo committed Sep 18, 2024
1 parent 7cead61 commit 8f3e5d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
36 changes: 18 additions & 18 deletions assets/details-disclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ class HeaderMenu extends DetailsDisclosure {
constructor() {
super();
this.header = document.querySelector('.header-wrapper');
this.megaMenu = document.querySelector('.mega-menu');
// this.megaMenu = document.querySelector('.mega-menu');
}

onToggle() {
if (this.megaMenu) {
var parentLinks = document.querySelectorAll('details.mega-menu');
parentLinks.forEach(function (parentLink) {
loadImages(parentLink);
});
function loadImages(menuItem) {
var images = menuItem.querySelectorAll('.custom-lazyload');
if (!images.length) return;
images.forEach(function (image) {
if (image.dataset.src) {
image.src = image.dataset.src;
image.removeAttribute('data-src');
image.classList.remove('custom-lazyload');
}
});
}
}
// if (this.megaMenu) {
// var parentLinks = document.querySelectorAll('details.mega-menu');
// parentLinks.forEach(function (parentLink) {
// loadImages(parentLink);
// });
// function loadImages(menuItem) {
// var images = menuItem.querySelectorAll('.custom-lazyload');
// if (!images.length) return;
// images.forEach(function (image) {
// if (image.dataset.src) {
// image.src = image.dataset.src;
// image.removeAttribute('data-src');
// image.classList.remove('custom-lazyload');
// }
// });
// }
// }

if (!this.header) return;
this.header.preventHide = this.mainDetailsToggle.open;
Expand Down
3 changes: 2 additions & 1 deletion snippets/header-mega-menu.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<img
width='160'
height='160'
class='twcss-aspect-square twcss-object-cover custom-lazyload'
class='twcss-aspect-square twcss-object-cover'
fetchpriority='low'
data-src='{{ block.settings.promotional_image | image_url }}'
alt='{{ block.settings.promotional_image.alt | escape }}'
>

Check warning on line 103 in snippets/header-mega-menu.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

snippets/header-mega-menu.liquid#L96-L103

[ImgLazyLoading] Use loading="eager" for images visible in the viewport on load and loading="lazy" for others
Expand Down

0 comments on commit 8f3e5d7

Please sign in to comment.