Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved issue with is_lcp_statically_discoverable #148

Merged
merged 3 commits into from
Nov 3, 2024

Conversation

kevinfarrugia
Copy link
Contributor

@kevinfarrugia kevinfarrugia commented Sep 25, 2024

The raw HTML (from response_body) uses relative URLs for images, for example "/static/img/logo.png", while calling .src on a document with a location, gives you absolute URLs, such as https://happymod.com/static/img/logo.png.

Consequently, when checking for the LCP element, we need to wrap the src with new URL to get an absolute URL.


Test websites:

@tunetheweb
Copy link
Member

@kevinfarrugia , @rviscomi is this good to merge?

@rviscomi
Copy link
Member

The change LGTM, I'm just not sure why the GH action isn't testing the URLs in the description

@max-ostapenko
Copy link
Contributor

The change LGTM, I'm just not sure why the GH action isn't testing the URLs in the description

Test websites: must be bold.

Copy link

github-actions bot commented Nov 3, 2024

https://almanac.httparchive.org/en/2022/

WPT result details

Changed custom metrics values:

{
  "_performance": {
    "lcp_elem_stats": {
      "startTime": 587.4000000059605,
      "nodeName": "IMG",
      "url": "https://almanac.httparchive.org/static/images/home-hero.png",
      "size": 161020,
      "loadTime": 371.79999999701977,
      "renderTime": 587.4000000059605,
      "attributes": [
        {
          "name": "src",
          "value": "/static/images/home-hero.png"
        },
        {
          "name": "alt",
          "value": ""
        },
        {
          "name": "width",
          "value": "820"
        },
        {
          "name": "height",
          "value": "562"
        },
        {
          "name": "fetchpriority",
          "value": "high"
        }
      ],
      "boundingClientRect": {
        "x": 866,
        "y": 281.90625,
        "width": 485,
        "height": 332.390625,
        "top": 281.90625,
        "right": 1351,
        "bottom": 614.296875,
        "left": 866
      },
      "naturalWidth": 820,
      "naturalHeight": 562,
      "styles": {
        "background-image": "none",
        "pointer-events": "auto",
        "position": "relative",
        "width": "485px",
        "height": "332.391px"
      },
      "percentOfViewport": "0.173",
      "cover90viewport": false
    },
    "raw_lcp_element": {
      "nodeName": "IMG",
      "attributes": [
        {
          "name": "src",
          "value": "/static/images/home-hero.png"
        },
        {
          "name": "alt",
          "value": ""
        },
        {
          "name": "width",
          "value": "820"
        },
        {
          "name": "height",
          "value": "562"
        },
        {
          "name": "fetchpriority",
          "value": "high"
        }
      ]
    },
    "lcp_resource": {
      "id": "8137.10",
      "sequence": 10,
      "body": "/home/pmeenan/wptagent/work/wptagent-v6-manual-20241002-10.20.0.3/241103_3P_4.1.0/bodies/8137.10",
      "url": "https://almanac.httparchive.org/static/images/home-hero.png",
      "status": 200,
      "connectionId": 104,
      "protocol": "h2",
      "connectionReused": true,
      "fromServiceWorker": false,
      "timing": {
        "requestTime": 72183.121683,
        "proxyStart": -1,
        "proxyEnd": -1,
        "dnsStart": -1,
        "dnsEnd": -1,
        "connectStart": -1,
        "connectEnd": -1,
        "sslStart": -1,
        "sslEnd": -1,
        "workerStart": -1,
        "workerReady": -1,
        "workerFetchStart": -1,
        "workerRespondWithSettled": -1,
        "sendStart": 6.042,
        "sendEnd": 6.874,
        "pushStart": 0,
        "pushEnd": 0,
        "receiveHeadersStart": 86.163,
        "receiveHeadersEnd": 86.364
      },
      "fromDiskCache": false,
      "remoteIPAddress": "[2607:f8b0:4004:c09::79]",
      "remotePort": 443,
      "securityState": "secure",
      "securityDetails": {
        "protocol": "TLS 1.3",
        "keyExchange": "",
        "keyExchangeGroup": "X25519",
        "cipher": "AES_128_GCM",
        "certificateId": 0,
        "subjectName": "almanac.httparchive.org",
        "sanList": [
          "almanac.httparchive.org"
        ],
        "issuer": "WR3",
        "validFrom": 1727304396,
        "validTo": 1735083387,
        "signedCertificateTimestampList": [
          {
            "status": "Verified",
            "origin": "Embedded in certificate",
            "logDescription": "Google 'Argon2024' log",
            "logId": "EECDD064D5DB1ACEC55CB79DB4CD13A23287467CBCECDEC351485946711FB59B",
            "timestamp": 1727307996591,
            "hashAlgorithm": "SHA-256",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "304402200A8C65426A2C199C8AC17FBA007F984B3D6F4FEF5E506EF0286F572DE1E6EF7A022037FD2EB1BCD8ACDD20B0B1576A1DD2146E99A0BA97D27C77301187683C781379"
          },
          {
            "status": "Verified",
            "origin": "Embedded in certificate",
            "logDescription": "DigiCert Yeti2024 Log",
            "logId": "48B0E36BDAA647340FE56A02FA9D30EB1C5201CB56DD2C81D9BBBFAB39D88473",
            "timestamp": 1727307996619,
            "hashAlgorithm": "SHA-256",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "3044022053D05AA53809107C6EB629BF5705A22947D13C234EF2869284383BF45B703B1D02203A5516D173801676735F525945B3D1643B6F8C9BF75F8EBDEB1790E3036A642A"
          }
        ],
        "certificateTransparencyCompliance": "compliant",
        "serverSignatureAlgorithm": 2052,
        "encryptedClientHello": false
      },
      "fromPrefetchCache": false,
      "response_headers": {
        "age": "9479",
        "cache-control": "public, max-age=10800",
        "content-length": "38042",
        "content-type": "image/png",
        "date": "Sun, 03 Nov 2024 14:09:07 GMT",
        "etag": "\"mq4XqA\"",
        "expires": "Sun, 03 Nov 2024 17:09:07 GMT",
        "server": "Google Frontend",
        "strict-transport-security": "max-age=31556926; includeSubDomains",
        "vary": "Accept-Encoding",
        "x-cloud-trace-context": "516fd671d8bda449fbd331e3d7a51d1d",
        "x-content-type-options": "nosniff"
      },
      "request_headers": {
        ":authority": "almanac.httparchive.org",
        ":method": "GET",
        ":path": "/static/images/home-hero.png",
        ":scheme": "https",
        "accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
        "accept-encoding": "gzip, deflate, br, zstd",
        "accept-language": "en-US,en;q=0.9",
        "priority": "u=1, i",
        "referer": "https://almanac.httparchive.org/en/2022/",
        "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Unknown\"",
        "sec-fetch-dest": "image",
        "sec-fetch-mode": "no-cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 PTST/241102.145121"
      },
      "initiator": {
        "type": "parser",
        "url": "https://almanac.httparchive.org/en/2022/",
        "lineNumber": 1402,
        "columnNumber": 99
      },
      "documentURL": "https://almanac.httparchive.org/en/2022/",
      "timestamp": 72183.103919,
      "frameId": "82A5A7F9EEB9EE494D040134AA27C9AB",
      "hasUserGesture": false,
      "type": "Image",
      "wallTime": 1730652426.814495,
      "initialPriority": "High",
      "priority": "High",
      "transfer_size": 38225
    },
    "is_lcp_statically_discoverable": true,
    "is_lcp_preloaded": false,
    "lcp_preload": [],
    "web_vitals_js": [
      "https://almanac.httparchive.org/static/js/web-vitals.js?v=94d123623c67f0e7774480cf1ad078cd"
    ],
    "gaming_metrics": [],
    "speculation_rules": [
      {
        "prerender": [
          {
            "source": "document",
            "where": {
              "and": [
                {
                  "href_matches": "/*"
                },
                {
                  "not": {
                    "href_matches": "/static/*"
                  }
                }
              ]
            },
            "eagerness": "moderate"
          }
        ]
      }
    ]
  }
}
https://happymod.com

WPT result details

Changed custom metrics values:

{
  "_performance": {
    "lcp_elem_stats": {
      "startTime": 2142.2999999970198,
      "nodeName": "IMG",
      "url": "https://happymod.com/static/img/hero_index.webp",
      "size": 288660,
      "loadTime": 1988.699999988079,
      "renderTime": 2142.2999999970198,
      "attributes": [
        {
          "name": "src",
          "value": "/static/img/hero_index.webp"
        },
        {
          "name": "class",
          "value": "hero_thumb lozad"
        },
        {
          "name": "width",
          "value": "510"
        },
        {
          "name": "height",
          "value": "566"
        },
        {
          "name": "alt",
          "value": "HappyMod"
        },
        {
          "name": "data-loaded",
          "value": "true"
        }
      ],
      "boundingClientRect": {
        "x": 720.5,
        "y": 95,
        "width": 510,
        "height": 566,
        "top": 95,
        "right": 1230.5,
        "bottom": 661,
        "left": 720.5
      },
      "naturalWidth": 510,
      "naturalHeight": 566,
      "styles": {
        "background-image": "none",
        "pointer-events": "auto",
        "position": "static",
        "width": "510px",
        "height": "566px"
      },
      "percentOfViewport": "0.310",
      "cover90viewport": false
    },
    "raw_lcp_element": {
      "nodeName": "IMG",
      "attributes": [
        {
          "name": "src",
          "value": "/static/img/hero_index.webp"
        },
        {
          "name": "class",
          "value": "hero_thumb lozad"
        },
        {
          "name": "width",
          "value": "510"
        },
        {
          "name": "height",
          "value": "566"
        },
        {
          "name": "alt",
          "value": "HappyMod"
        }
      ]
    },
    "lcp_resource": {
      "id": "8751.8",
      "sequence": 4,
      "body": "/home/pmeenan/wptagent/work/wptagent-v6-manual-20241002-10.20.0.3/241103_P3_5.1.0/bodies/8751.8",
      "url": "https://happymod.com/static/img/hero_index.webp",
      "status": 200,
      "connectionId": 0,
      "protocol": "h3",
      "connectionReused": true,
      "fromServiceWorker": false,
      "timing": {
        "requestTime": 72224.749163,
        "proxyStart": -1,
        "proxyEnd": -1,
        "dnsStart": -1,
        "dnsEnd": -1,
        "connectStart": -1,
        "connectEnd": -1,
        "sslStart": -1,
        "sslEnd": -1,
        "workerStart": -1,
        "workerReady": -1,
        "workerFetchStart": -1,
        "workerRespondWithSettled": -1,
        "sendStart": 2.179,
        "sendEnd": 2.639,
        "pushStart": 0,
        "pushEnd": 0,
        "receiveHeadersStart": 40.06,
        "receiveHeadersEnd": 40.426
      },
      "fromDiskCache": false,
      "remoteIPAddress": "[2606:4700:3031::6815:409c]",
      "remotePort": 443,
      "securityState": "secure",
      "securityDetails": {
        "protocol": "QUIC",
        "keyExchange": "",
        "keyExchangeGroup": "X25519Kyber768Draft00",
        "cipher": "AES_128_GCM",
        "certificateId": 0,
        "subjectName": "happymod.com",
        "sanList": [
          "happymod.com",
          "*.happymod.com"
        ],
        "issuer": "WE1",
        "validFrom": 1729710675,
        "validTo": 1737486674,
        "signedCertificateTimestampList": [
          {
            "status": "Verified",
            "origin": "Embedded in certificate",
            "logDescription": "Google 'Xenon2025h1' log",
            "logId": "CF1156EED52E7CAFF3875BD9692E9BE91A71674AB017ECAC01D25B77CECC3B08",
            "timestamp": 1729714276345,
            "hashAlgorithm": "SHA-256",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "304502203594963D840836CB416B02A71567224060DF411FCC8CEBCFBFCC7DC1DFB45E73022100A9FC9CCDE181ECCD51993293D7A600B74C0EEBCAC830731217F759B2A0B4DE1A"
          },
          {
            "status": "Verified",
            "origin": "Embedded in certificate",
            "logDescription": "DigiCert Yeti2025 Log",
            "logId": "7D591E12E1782A7B1C61677C5EFDF8D0875C14A04E959EB9032FD90E8C2E79B8",
            "timestamp": 1729714276327,
            "hashAlgorithm": "SHA-256",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "3045022100CD6027ECBC64C780CFB9938045D4819C3BAEE598C3B00C320BEB2100AE6EA67302206778DA882D653A6A7359BDD77C34D41DE01BDCF49DA08FF9C2A201E4C669D3C7"
          }
        ],
        "certificateTransparencyCompliance": "compliant",
        "serverSignatureAlgorithm": 1027,
        "encryptedClientHello": true
      },
      "fromPrefetchCache": false,
      "response_headers": {
        "accept-ranges": "bytes",
        "age": "1038537",
        "alt-svc": "h3=\":443\"; ma=86400",
        "cache-control": "max-age=2592000",
        "cf-cache-status": "HIT",
        "cf-ray": "8dcdd9280d865722-IAD",
        "content-length": "14894",
        "content-type": "image/webp",
        "date": "Sun, 03 Nov 2024 16:47:48 GMT",
        "etag": "\"6600ee79-3a2e\"",
        "expires": "Thu, 21 Nov 2024 16:18:51 GMT",
        "last-modified": "Mon, 25 Mar 2024 03:24:41 GMT",
        "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
        "report-to": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=b6KmWIEadueIUL7qfwU0U0AIwTJSydi2eTgxJqq3iYI9ySuevD7zLyJW4mwua3ebUwkNmaD%2BHnpkvy8CG%2BpWNBByN4GVzL4bwoWf79OOfb02MEzxaSWVWsf40a3sbnUTdZnnqgf3%2FIs%2FHUc%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
        "server": "cloudflare",
        "server-timing": "cfL4;desc=\"?proto=QUIC&rtt=26773&sent=36&recv=21&lost=0&retrans=0&sent_bytes=26249&recv_bytes=6241&delivery_rate=723269&cwnd=16800&unsent_bytes=0&cid=a56547c6e692c742&ts=1810&x=1\"\ncfHdrFlush;dur=0",
        "vary": "Accept-Encoding"
      },
      "request_headers": {
        ":authority": "happymod.com",
        ":method": "GET",
        ":path": "/static/img/hero_index.webp",
        ":scheme": "https",
        "accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
        "accept-encoding": "gzip, deflate, br, zstd",
        "accept-language": "en-US,en;q=0.9",
        "priority": "u=2, i",
        "referer": "https://happymod.com/",
        "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Unknown\"",
        "sec-fetch-dest": "image",
        "sec-fetch-mode": "no-cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 PTST/241102.145121"
      },
      "initiator": {
        "type": "parser",
        "url": "https://happymod.com/",
        "lineNumber": 337,
        "columnNumber": 153
      },
      "documentURL": "https://happymod.com/",
      "timestamp": 72224.732463,
      "frameId": "A46A97B391BCC65FE46F0DB869F5073E",
      "hasUserGesture": false,
      "type": "Image",
      "wallTime": 1730652468.443032,
      "initialPriority": "Medium",
      "priority": "High",
      "transfer_size": 15565
    },
    "is_lcp_statically_discoverable": true,
    "is_lcp_preloaded": false,
    "lcp_preload": [],
    "web_vitals_js": [],
    "gaming_metrics": [],
    "speculation_rules": []
  }
}
https://httparchive.org

WPT result details

Changed custom metrics values:

{
  "_performance": {
    "lcp_elem_stats": {
      "startTime": 435.70000000298023,
      "nodeName": "IMG",
      "url": "https://httparchive.org/static/img/web.png",
      "size": 211718,
      "loadTime": 292.5,
      "renderTime": 435.70000000298023,
      "attributes": [
        {
          "name": "src",
          "value": "/static/img/web.png"
        },
        {
          "name": "alt",
          "value": ""
        },
        {
          "name": "width",
          "value": "457"
        },
        {
          "name": "height",
          "value": "495"
        },
        {
          "name": "aria-label",
          "value": "HTTP Archive reports"
        }
      ],
      "boundingClientRect": {
        "x": 123.5,
        "y": 156,
        "width": 442.5,
        "height": 479.28125,
        "top": 156,
        "right": 566,
        "bottom": 635.28125,
        "left": 123.5
      },
      "naturalWidth": 457,
      "naturalHeight": 495,
      "styles": {
        "background-image": "none",
        "pointer-events": "auto",
        "position": "static",
        "width": "442.5px",
        "height": "479.281px"
      },
      "percentOfViewport": "0.228",
      "cover90viewport": false
    },
    "raw_lcp_element": {
      "nodeName": "IMG",
      "attributes": [
        {
          "name": "src",
          "value": "/static/img/web.png"
        },
        {
          "name": "alt",
          "value": ""
        },
        {
          "name": "width",
          "value": "457"
        },
        {
          "name": "height",
          "value": "495"
        },
        {
          "name": "aria-label",
          "value": "HTTP Archive reports"
        }
      ]
    },
    "lcp_resource": {
      "id": "9704.10",
      "sequence": 10,
      "body": "/home/pmeenan/wptagent/work/wptagent-v6-manual-20241002-10.20.0.3/241103_2N_6.1.0/bodies/9704.10",
      "url": "https://httparchive.org/static/img/web.png",
      "status": 200,
      "connectionId": 100,
      "protocol": "h2",
      "connectionReused": true,
      "fromServiceWorker": false,
      "timing": {
        "requestTime": 72262.592789,
        "proxyStart": -1,
        "proxyEnd": -1,
        "dnsStart": -1,
        "dnsEnd": -1,
        "connectStart": -1,
        "connectEnd": -1,
        "sslStart": -1,
        "sslEnd": -1,
        "workerStart": -1,
        "workerReady": -1,
        "workerFetchStart": -1,
        "workerRespondWithSettled": -1,
        "sendStart": 4.418,
        "sendEnd": 5.671,
        "pushStart": 0,
        "pushEnd": 0,
        "receiveHeadersStart": 38.353,
        "receiveHeadersEnd": 38.548
      },
      "fromDiskCache": false,
      "remoteIPAddress": "[2001:4860:4802:32::15]",
      "remotePort": 443,
      "securityState": "secure",
      "securityDetails": {
        "protocol": "TLS 1.3",
        "keyExchange": "",
        "keyExchangeGroup": "X25519",
        "cipher": "AES_128_GCM",
        "certificateId": 0,
        "subjectName": "httparchive.org",
        "sanList": [
          "httparchive.org"
        ],
        "issuer": "WR3",
        "validFrom": 1727829046,
        "validTo": 1735607896,
        "signedCertificateTimestampList": [
          {
            "status": "Verified",
            "origin": "Embedded in certificate",
            "logDescription": "Google 'Xenon2024' log",
            "logId": "76FF883F0AB6FB9551C261CCF587BA34B4A4CDBB29DC68420A9FE6674C5A3A74",
            "timestamp": 1727832647239,
            "hashAlgorithm": "SHA-256",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "304402201A538B7FA938F0FB3EE0546EDABDF92B5F9505D36129CF1924799E917D358A320220066D19FFDCF1C1A9485F5CE7270AD9816ADBD699D1444751FD0A41FCD879733F"
          },
          {
            "status": "Verified",
            "origin": "Embedded in certificate",
            "logDescription": "DigiCert Yeti2024 Log",
            "logId": "48B0E36BDAA647340FE56A02FA9D30EB1C5201CB56DD2C81D9BBBFAB39D88473",
            "timestamp": 1727832647224,
            "hashAlgorithm": "SHA-256",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "3045022033F2505698B2DDEC307B6E2DA9E10BEFD512D5792EBFF40F6E4F0A0DB6C1335D022100AAF8B27F73CEC52FA1C7A3486A3F11E8F96082A57C6AA416BDA6C9F7A71BB1C1"
          }
        ],
        "certificateTransparencyCompliance": "compliant",
        "serverSignatureAlgorithm": 2052,
        "encryptedClientHello": false
      },
      "fromPrefetchCache": false,
      "response_headers": {
        "age": "10558",
        "cache-control": "public, max-age=10800",
        "content-length": "13951",
        "content-type": "image/png",
        "date": "Sun, 03 Nov 2024 13:52:28 GMT",
        "etag": "\"AAqk1Q\"",
        "expires": "Sun, 03 Nov 2024 16:52:28 GMT",
        "server": "Google Frontend",
        "strict-transport-security": "max-age=31556926; includeSubDomains",
        "vary": "Accept-Encoding",
        "x-cloud-trace-context": "6253f387fc0ad2da6de4c080a136a086;o=1",
        "x-content-type-options": "nosniff"
      },
      "request_headers": {
        ":authority": "httparchive.org",
        ":method": "GET",
        ":path": "/static/img/web.png",
        ":scheme": "https",
        "accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
        "accept-encoding": "gzip, deflate, br, zstd",
        "accept-language": "en-US,en;q=0.9",
        "priority": "u=2, i",
        "referer": "https://httparchive.org/",
        "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Unknown\"",
        "sec-fetch-dest": "image",
        "sec-fetch-mode": "no-cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 PTST/241102.145121"
      },
      "initiator": {
        "type": "parser",
        "url": "https://httparchive.org/",
        "lineNumber": 263,
        "columnNumber": 106
      },
      "documentURL": "https://httparchive.org/",
      "timestamp": 72262.580256,
      "frameId": "276DB3CB18820245CE9F77B29284AFA0",
      "hasUserGesture": false,
      "type": "Image",
      "wallTime": 1730652506.290829,
      "initialPriority": "Medium",
      "priority": "Medium",
      "transfer_size": 14094
    },
    "is_lcp_statically_discoverable": true,
    "is_lcp_preloaded": false,
    "lcp_preload": [],
    "web_vitals_js": [
      "https://httparchive.org/static/js/web-vitals.js?v=94d123623c67f0e7774480cf1ad078cd"
    ],
    "gaming_metrics": [],
    "speculation_rules": []
  }
}

@tunetheweb tunetheweb merged commit 420b19b into HTTPArchive:main Nov 3, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants