Remove erroneous check for resource initiator type when considering whether to submit LCP background image#1760
Merged
westonruter merged 2 commits intotrunkfrom Dec 19, 2024
Merged
Conversation
…ether to submit external background image
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When setting up a demo site with Optimization Detective, I was confused when I wasn't getting the
lcpElementExternalBackgroundImagedata submitted with the URL Metric. In looking at the console, I saw:This was strange because the LCP element was definitely using a
background-imagecoming from a stylesheet:Nevertheless, the
initiatorTypeof the resource was coming through as animgand not ascss. Then I looked further down the page and I found the same image was being used in anIMGtag:This actually reveals an interesting performance fact: even though the image is being used as a background image for the LCP element, there is an image way further down the page which is actually initiating the loading of this image before the stylesheet is initiating the load. Even more surprising, this
IMGhasloading=lazy. This highlights the need for adding a preload link for this image URL so that it is properly prioritized!Granted, it may be unlikely for the exact same image used as the LCP element's background to also appear further down the page in non-example content. In any case, checking the
initiatorTypefor the resource was redundant because it's already aborting if the LCP element is anIMGtag:performance/plugins/image-prioritizer/detect.js
Lines 90 to 98 in 2033d44
Therefore, there is no need for the additional check.