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

Very large transparent SVG should not count as LCP #72

Open
rik opened this issue Feb 12, 2021 · 5 comments · May be fixed by #115
Open

Very large transparent SVG should not count as LCP #72

rik opened this issue Feb 12, 2021 · 5 comments · May be fixed by #115

Comments

@rik
Copy link

rik commented Feb 12, 2021

This technique is floating around to game the metric.

<img
    width="99999"
    height="99999"
    style="pointer-events: none;
        position: absolute;
        top: 0; left: 0;
        width: 99vw; height: 99vh;
        max-width: 99vw; max-height: 99vh;"
    src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSI5OTk5OXB4IiBoZWlnaHQ9Ijk5OTk5cHgiIHZpZXdCb3g9IjAgMCA5OTk5OSA5OTk5OSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48ZyBzdHJva2U9Im5vbmUiIGZpbGw9Im5vbmUiIGZpbGwtb3BhY2l0eT0iMCI+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9Ijk5OTk5IiBoZWlnaHQ9Ijk5OTk5Ij48L3JlY3Q+IDwvZz4gPC9zdmc+"
>

The base64 string encodes the following SVG

<svg width="99999px" height="99999px" viewBox="0 0 99999 99999" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g stroke="none" fill="none" fill-opacity="0">
        <rect x="0" y="0" width="99999" height="99999"></rect>
    </g>
</svg>
@yoavweiss
Copy link
Contributor

I agree this should not count as LCP, as the metric should be well-aligned with user experience, and this hack prevents that alignment and erodes trust in the metric.

/cc @clelland

@noamr
Copy link
Contributor

noamr commented May 13, 2022

Not sure there is a solution to hermetically seal against this type of hack in the spec, even if we introduce some intricate solution specifically for SVG with only transparent elements.

I think the solution for this lies outside the standard LCP metric - to detect LCP fraud in whatever piece relies on LCP for rewarding/penalizing the site somehow (e.g. search-engine ranking and the likes).

@noamr
Copy link
Contributor

noamr commented May 13, 2022

One thing that comes to mind though is to somehow take overlapping elements into account. If you have something big and then a lot of small things start to come and overlap with it, only count the non-overlapping parts as "early".
Something like this:

  • When a large image (SVG or otherwise) appears, it gets its full LCP candidate entry
  • As more elements are added that overlap with it, the overlap area is deduced from the size of that early LCP

@onlinebizsoft
Copy link

@clelland
Copy link
Collaborator

It should solve that; I just need to write it up as a spec change before this can be closed.

@clelland clelland linked a pull request Aug 31, 2023 that will close this issue
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 a pull request may close this issue.

5 participants