sitespeedio / coach-core

Core functionality for the Coach
MIT License
1 stars 5 forks source link

Look for fetchPriority instead of importance #103

Open fariasf opened 1 year ago

fariasf commented 1 year ago

In https://github.com/sitespeedio/coach-core/blob/aa2654879533af3ec0381acaf9e7f0b1bfe84c30/lib/dom/performance/largestContentfulPaint.js#L44C1-L49 The Coach will take 5 points if the LCP element is an img and it misses the importance="high" attribute.

According to https://web.dev/fetch-priority/#history, this attribute is now fetchPriority:

Fetch Priority was first experimented with in Chrome as an origin trial in 2018 and then again in 2021 using the importance attribute. At that time it was known as Priority Hints. The interface has since changed to fetchpriority for HTML and priority for JavaScript's Fetch API as part of the web standards process. To reduce confusion we now refer to this API as Fetch Priority.

I've tried adding both attributes to get a perfect score there, but I think doesn't work in recent versions of Chrome as it already moved to fetchPriority (testing manually in the JS console, markup for lcp_image is <img importance="high" fetchpriority="high" src=...):

lcp_image.importance
undefined
lcp_image.fetchPriority
'high'
soulgalore commented 1 year ago

Thanks I'll have look before the next release.