Skip to content

Commit

Permalink
Address Roberts PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mokimo committed Oct 24, 2024
1 parent bf735ab commit d5c22fe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/blocks/preflight/panels/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ export function conditionalItemUpdate({ emptyWhen, failsWhen, key }) {
// in bytes is >= candidate’s element's effective visual size * 0.004
export async function checkImageSize() {
const { lcp } = config;
const hasValidImage = lcp?.url && !lcp.url.match('media_.*.mp4');
let hasValidImage = lcp?.url && !lcp.url.match('media_.*.mp4');
let blob;
let isSizeValid;
if (hasValidImage) {
blob = await fetch(lcp.url).then((res) => res.blob());
isSizeValid = blob.size / 1024 <= 100;
try {
blob = await fetch(lcp.url).then((res) => res.blob());
isSizeValid = blob.size / 1024 <= 100;
} catch (error) {
hasValidImage = false;
}

Check warning on line 110 in libs/blocks/preflight/panels/performance.js

View check run for this annotation

Codecov / codecov/patch

libs/blocks/preflight/panels/performance.js#L109-L110

Added lines #L109 - L110 were not covered by tests
}

conditionalItemUpdate({
Expand All @@ -120,7 +124,6 @@ export function checkLCP() {
conditionalItemUpdate({
failsWhen: !validLcp,
key: text.lcpEl.key,
icon: icons.pass,
description: text.lcpEl.passed.description,
});
return validLcp;
Expand Down

0 comments on commit d5c22fe

Please sign in to comment.