diff --git a/lighthouse-core/gather/gatherers/dobetterweb/optimized-images.js b/lighthouse-core/gather/gatherers/dobetterweb/optimized-images.js index 52d029625b8e..b06a548519ea 100644 --- a/lighthouse-core/gather/gatherers/dobetterweb/optimized-images.js +++ b/lighthouse-core/gather/gatherers/dobetterweb/optimized-images.js @@ -71,7 +71,13 @@ class OptimizedImages extends Gatherer { * @return {!Array<{url: string, isBase64DataUri: boolean, mimeType: string, resourceSize: number}>} */ static filterImageRequests(pageUrl, networkRecords) { + const seenUrls = new Set(); return networkRecords.reduce((prev, record) => { + if (seenUrls.has(record._url)) { + return prev; + } + + seenUrls.add(record._url); const isOptimizableImage = /image\/(png|bmp|jpeg)/.test(record._mimeType); const isSameOrigin = URL.hostsMatch(pageUrl, record._url); const isBase64DataUri = /^data:.{2,40}base64\s*,/.test(record._url); diff --git a/lighthouse-core/test/gather/gatherers/dobetterweb/optimized-images-test.js b/lighthouse-core/test/gather/gatherers/dobetterweb/optimized-images-test.js index 996924a19e88..8473686bcaaa 100644 --- a/lighthouse-core/test/gather/gatherers/dobetterweb/optimized-images-test.js +++ b/lighthouse-core/test/gather/gatherers/dobetterweb/optimized-images-test.js @@ -44,6 +44,11 @@ const traceData = { _mimeType: 'image/bmp', _resourceSize: 12, }, + { + _url: 'http://google.com/image.bmp', + _mimeType: 'image/bmp', + _resourceSize: 12, + }, { _url: 'http://google.com/vector.svg', _mimeType: 'image/svg+xml',