diff --git a/plugins/image-prioritizer/detect.js b/plugins/image-prioritizer/detect.js index 54fe64d09..63c1c2770 100644 --- a/plugins/image-prioritizer/detect.js +++ b/plugins/image-prioritizer/detect.js @@ -43,18 +43,6 @@ function log( ...message ) { console.log( consoleLogPrefix, ...message ); } -/** - * Logs a warning. - * - * @since 0.3.0 - * - * @param {...*} message - */ -function warn( ...message ) { - // eslint-disable-next-line no-console - console.warn( consoleLogPrefix, ...message ); -} - /** * Initializes extension. * @@ -77,27 +65,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. * @@ -129,21 +96,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 ) {