Skip to content

[MWPW-189469] Eager loading of media in upload marquee#905

Open
vipu0303 wants to merge 16 commits intostagefrom
vg-db5
Open

[MWPW-189469] Eager loading of media in upload marquee#905
vipu0303 wants to merge 16 commits intostagefrom
vg-db5

Conversation

@vipu0303
Copy link
Collaborator

@vipu0303 vipu0303 commented Mar 6, 2026

@aem-code-sync
Copy link

aem-code-sync bot commented Mar 6, 2026

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

@aem-code-sync
Copy link

aem-code-sync bot commented Mar 6, 2026

return 'TABLET';
}

export { defineDeviceByScreenSize };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you could use getScreenSizeCategory from utils.js


function getBaseImageUrlFromPicture(picture) {
const img = picture?.querySelector('img');
const src = img?.getAttribute('src');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could img.src directly instead of getAttribute, which is cleaner and slightly faster.

const src = img?.getAttribute('src');
if (src) return src.split('?')[0];
const source = picture?.querySelector('source[srcset]');
const srcset = source?.getAttribute('srcset');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could source.srcset directly instead of getAttribute, which is cleaner and slightly faster.

const firstUrl = srcset.split(',')[0].trim().split(/\s+/)[0];
return firstUrl ? firstUrl.split('?')[0] : null;
}
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do an early return for missing picture

A tighter version could be:

function getBaseImageUrlFromPicture(picture) {
  if (!picture) return null;

  const imgSrc = picture.querySelector('img')?.src;
  if (imgSrc) return imgSrc.split('?')[0];

  const srcset = picture.querySelector('source[srcset]')?.srcset;
  if (!srcset) return null;

  const url = srcset.split(',')[0].trim().split(/\s+/)[0];
  return url ? url.split('?')[0] : null;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants