Skip to content

Allow fetchpriority=high to be added to IMG when it is the LCP element on desktop and mobile with other viewport groups empty #1710

@westonruter

Description

@westonruter

Image Prioritizer currently removes or doesn't add fetchpriority=high to an IMG unless every viewport group is populated and each has an LCP element with the same XPath. I think this may be too conservative, especially since many sites may get very few phablet and tablet visitors meaning those URL Metric groups never get populated. I think we should perhaps align with what we're now doing for lazy-loading (#1604), where it does so if the narrowest viewport group (i.e. mobile) and the widest viewport group (i.e. desktop) both are populated. In the same way, if the mobile viewport group and the desktop viewport group both have the same LCP element (i.e. the same XPath) then we can in this case add fetchpriority=high to the IMG itself. Naturally, if the phablet and/or tablet viewport groups are also populated and they record a different LCP element, then fetchpriority=high should still be omitted.

In practice this won't really impact most visitors since the fetchpriority=high preload links area being added for each populated viewport group, but if there were no URL Metrics gathered for phablet/tablet and there is a shared LCP element on mobile & desktop, then there would not be any preload link for the phablet/tablet device. In this case, the presence of fetchpriority=high on the IMG itself would ensure they still get a performance improvement. This is also especially important for the case of optimizing PICTURE elements which have art-directed SOURCE images (with media attributes), in which case adding preload links is not feasible.

Previously discussed at #1707 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Plugin] Image PrioritizerIssues for the Image Prioritizer plugin (dependent on Optimization Detective)[Plugin] Optimization DetectiveIssues for the Optimization Detective plugin[Type] EnhancementA suggestion for improvement of an existing feature

    Projects

    Status

    Done 😃

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions