Conversation
…uld not be nested
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
|
|
nkthakur48
requested changes
Mar 6, 2026
creativecloud/scripts/utils.js
Outdated
| return 'TABLET'; | ||
| } | ||
|
|
||
| export { defineDeviceByScreenSize }; |
Collaborator
There was a problem hiding this comment.
See if you could use getScreenSizeCategory from utils.js
|
|
||
| function getBaseImageUrlFromPicture(picture) { | ||
| const img = picture?.querySelector('img'); | ||
| const src = img?.getAttribute('src'); |
Collaborator
There was a problem hiding this comment.
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'); |
Collaborator
There was a problem hiding this comment.
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; |
Collaborator
There was a problem hiding this comment.
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;
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eager loading of the LCP image in upload marquee to improve performance.
Resolves: MWPW-189649
Test URLs: