{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/107267211","pull_request_review_id":28229335,"id":107267211,"diff_hunk":"@@ -36,9 +36,46 @@ function collectImageElementInfo() {\n       clientHeight: element.clientHeight,\n       naturalWidth: element.naturalWidth,\n       naturalHeight: element.naturalHeight,\n+      isCss: false,\n       isPicture: element.parentElement.tagName === 'PICTURE',\n     };\n   });\n+\n+  // Chrome normalizes background image style from getComputedStyle to be an absolute URL in quotes.\n+  // Only match basic background-image: url(\"http://host/image.jpeg\") declarations\n+  const CSS_URL_REGEX = /^url\\(\"([^\"]+)\"\\)$/;\n+  // Only find images that aren't specifically scaled\n+  const CSS_SIZE_REGEX = /(auto|contain|cover)/;\n+  const cssImages = [...document.querySelectorAll('*')].reduce((images, element) => {\n+    const style = window.getComputedStyle(element);\n+    if (!CSS_URL_REGEX.test(style.backgroundImage) ||\n+        !CSS_SIZE_REGEX.test(style.backgroundSize)) {\n+      return images;\n+    }\n+\n+    const imageMatch = style.backgroundImage.match(CSS_URL_REGEX);\n+    const url = imageMatch[1];\n+\n+    // Heuristic to filter out sprite sheets\n+    const differentImages = images.filter(image => image.src !== url);\n+    if (images.length - differentImages.length > 2) {\n+      return differentImages;\n+    }\n+\n+    images.push({\n+      src: url,\n+      clientWidth: element.clientWidth,\n+      clientHeight: element.clientHeight,\n+      naturalWidth: Number.MAX_VALUE,\n+      naturalHeight: Number.MAX_VALUE,","path":"lighthouse-core/gather/gatherers/image-usage.js","position":49,"original_position":49,"commit_id":"edbaaba72cb0a18a81b96568f745aba8ea6d5236","original_commit_id":"edbaaba72cb0a18a81b96568f745aba8ea6d5236","user":{"login":"patrickhulce","id":2301202,"avatar_url":"https://avatars1.githubusercontent.com/u/2301202?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickhulce","html_url":"https://github.com/patrickhulce","followers_url":"https://api.github.com/users/patrickhulce/followers","following_url":"https://api.github.com/users/patrickhulce/following{/other_user}","gists_url":"https://api.github.com/users/patrickhulce/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickhulce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickhulce/subscriptions","organizations_url":"https://api.github.com/users/patrickhulce/orgs","repos_url":"https://api.github.com/users/patrickhulce/repos","events_url":"https://api.github.com/users/patrickhulce/events{/privacy}","received_events_url":"https://api.github.com/users/patrickhulce/received_events","type":"User","site_admin":false},"body":"yup, will do","created_at":"2017-03-21T20:32:23Z","updated_at":"2017-03-21T20:32:23Z","html_url":"https://github.com/GoogleChrome/lighthouse/pull/1868#discussion_r107267211","pull_request_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/107267211"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/1868#discussion_r107267211"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868","id":110995239,"html_url":"https://github.com/GoogleChrome/lighthouse/pull/1868","diff_url":"https://github.com/GoogleChrome/lighthouse/pull/1868.diff","patch_url":"https://github.com/GoogleChrome/lighthouse/pull/1868.patch","issue_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1868","number":1868,"state":"open","locked":false,"title":"feat(image-usage): add support for CSS images","user":{"login":"patrickhulce","id":2301202,"avatar_url":"https://avatars1.githubusercontent.com/u/2301202?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickhulce","html_url":"https://github.com/patrickhulce","followers_url":"https://api.github.com/users/patrickhulce/followers","following_url":"https://api.github.com/users/patrickhulce/following{/other_user}","gists_url":"https://api.github.com/users/patrickhulce/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickhulce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickhulce/subscriptions","organizations_url":"https://api.github.com/users/patrickhulce/orgs","repos_url":"https://api.github.com/users/patrickhulce/repos","events_url":"https://api.github.com/users/patrickhulce/events{/privacy}","received_events_url":"https://api.github.com/users/patrickhulce/received_events","type":"User","site_admin":false},"body":"fixes #978\r\n\r\nSupports an MVP of responsive CSS images. The area here is a lot more gray than with HTML image elements, so I've kept it very limited in scope, but I believe it should cover the most naive case that's likely to have bloated images.\r\n\r\nAfter this lands, I'd like to do some cleanup so that we're not potentially fetching images multiple times in the optimized image gatherer and this one.","created_at":"2017-03-16T05:16:11Z","updated_at":"2017-03-21T20:32:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77d9f0d46b8be825fb8aaebeaa44b3666f764256","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1868/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/edbaaba72cb0a18a81b96568f745aba8ea6d5236","head":{"label":"GoogleChrome:css_images","ref":"css_images","sha":"edbaaba72cb0a18a81b96568f745aba8ea6d5236","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars0.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":53370988,"name":"lighthouse","full_name":"GoogleChrome/lighthouse","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars0.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/lighthouse","description":"Auditing, performance metrics, and best practices for Progressive Web Apps","fork":false,"url":"https://api.github.com/repos/GoogleChrome/lighthouse","forks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/forks","keys_url":"https://api.github.com/repos/GoogleChrome/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/lighthouse/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/events","assignees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/lighthouse/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/lighthouse/merges","archive_url":"https://api.github.com/repos/GoogleChrome/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/lighthouse/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/deployments","created_at":"2016-03-08T01:03:11Z","updated_at":"2017-03-21T17:58:54Z","pushed_at":"2017-03-21T19:22:07Z","git_url":"git://github.com/GoogleChrome/lighthouse.git","ssh_url":"git@github.com:GoogleChrome/lighthouse.git","clone_url":"https://github.com/GoogleChrome/lighthouse.git","svn_url":"https://github.com/GoogleChrome/lighthouse","homepage":"https://developers.google.com/web/tools/lighthouse/","size":12672,"stargazers_count":7809,"watchers_count":7809,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":319,"mirror_url":null,"open_issues_count":252,"forks":319,"open_issues":252,"watchers":7809,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"7824c3fff4e01712a17c6df0ab36007ec4b9b724","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars0.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":53370988,"name":"lighthouse","full_name":"GoogleChrome/lighthouse","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars0.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/lighthouse","description":"Auditing, performance metrics, and best practices for Progressive Web Apps","fork":false,"url":"https://api.github.com/repos/GoogleChrome/lighthouse","forks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/forks","keys_url":"https://api.github.com/repos/GoogleChrome/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/lighthouse/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/events","assignees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/lighthouse/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/lighthouse/merges","archive_url":"https://api.github.com/repos/GoogleChrome/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/lighthouse/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/deployments","created_at":"2016-03-08T01:03:11Z","updated_at":"2017-03-21T17:58:54Z","pushed_at":"2017-03-21T19:22:07Z","git_url":"git://github.com/GoogleChrome/lighthouse.git","ssh_url":"git@github.com:GoogleChrome/lighthouse.git","clone_url":"https://github.com/GoogleChrome/lighthouse.git","svn_url":"https://github.com/GoogleChrome/lighthouse","homepage":"https://developers.google.com/web/tools/lighthouse/","size":12672,"stargazers_count":7809,"watchers_count":7809,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":319,"mirror_url":null,"open_issues_count":252,"forks":319,"open_issues":252,"watchers":7809,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/1868"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1868"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1868/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1868/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/edbaaba72cb0a18a81b96568f745aba8ea6d5236"}}}}
{"actor":{"display_login":"patrickhulce"}}