Skip to content

Commit

Permalink
Remove erroneous check for resource initiatorType when considering wh…
Browse files Browse the repository at this point in the history
…ether to submit external background image
  • Loading branch information
westonruter committed Dec 19, 2024
1 parent c446d8c commit 2033d44
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions plugins/image-prioritizer/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ export async function initialize( { isDebug, onLCP } ) {
);
}

/**
* Gets the performance resource entry for a given URL.
*
* @since 0.3.0
*
* @param {string} url - Resource URL.
* @return {PerformanceResourceTiming|null} Resource entry or null.
*/
function getPerformanceResourceByURL( url ) {
const entries =
/** @type PerformanceResourceTiming[] */ performance.getEntriesByType(
'resource'
);
for ( const entry of entries ) {
if ( entry.name === url ) {
return entry;
}
}
return null;
}

/**
* Handles a new LCP metric being reported.
*
Expand Down Expand Up @@ -129,21 +108,6 @@ function handleLCPMetric( metric, isDebug ) {
continue;
}

// Now only consider proceeding with the URL if its loading was initiated with stylesheet or preload link.
const resourceEntry = getPerformanceResourceByURL( entry.url );
if (
! resourceEntry ||
! [ 'css', 'link' ].includes( resourceEntry.initiatorType )
) {
if ( isDebug ) {
warn(
`Skipped considering URL (${ entry.url }) due to unexpected performance resource timing entry:`,
resourceEntry
);
}
return;
}

// Skip URLs that are excessively long. This is the maxLength defined in image_prioritizer_add_element_item_schema_properties().
if ( entry.url.length > 500 ) {
if ( isDebug ) {
Expand Down

0 comments on commit 2033d44

Please sign in to comment.