Add meta attributes to preloaded tags and preload links for Image Prioritizer #1742
+62
−15
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.
Important
This is a sub-PR of #1713 and should not be merged before that is merged.
Debugging optimizations applied by Image Prioritizer involves identifying why a given preload link is added or attempting to connect a preload link with the underlying element that caused the preload link to be added in the first place. This can be done by implicitly by looking at attributes like connecting a preload link's
imagesrcset
attribute with thesrcset
attribute of someIMG
on the page. However, this gets more complicated with #1713 where background images applied with stylesheets are preloaded since there is no reference to the image URL in the HTML source. To assist with this, I'm considering whether we should adddata-od-preloaded
attributes to tags which have associated preload links, and conversely for the preload links to havedata-od-related-tag-selector
which helps to identify the element that the preload link was added for.For example, the following change would be applied to the
lcp-element-external-background-image-present-in-document-and-fully-populated-samples
test case:The work to update all of the test cases with these new changes would be tedious, so I haven't updated them yet. This would be a good opportunity to implement #1418 to eliminate this tediousness here and in the future.
Using a CSS selector as opposed to the already-made XPath is just something I was considering. By not including the element index which is present in the XPath it could make it easier to locate the element after JS has manipulated the DOM structure after page load.