-
Notifications
You must be signed in to change notification settings - Fork 288
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
feat: allow to specify preload fetch priority #989
Conversation
@dargmuesli What would be the reason to have this functionality? If you set preload it would most probably mean that you would like the image to have a high priority IMO. Setting it to auto may result in some issues of having a preload and fetchPriority low. If I get this completely wrong, please let me know. Maybe I am missing something :) |
Of course the main goal is to be able to specify "high" fetch priority for a preloaded image. I just included "low" and "auto" as it's part of the specification. |
@dargmuesli Isnt it set already by default? I thought it is set like that when passing preload. I was looking recently at the unpic library where this is done automatically so maybe I assumed that it is done here as well: If it doesnt work like that, please ignore my previous comment and proceed with thw implementation. Just review the question from Daniel and you should be good to go 😉 Also, I just noticed an issue with the GitHub Actions. Could you check this out as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments from my side
I tried it in Firefox. Using preload only let the request have low priority afair, setting it to high made let it be of high priority. |
any resolution for this PR? |
I resolved the merge conflicts. Reviews welcome! |
I'm not sure, but to me it looks like the netlify image cdn snapshot need to be updated. If that's incorrect, I'd need assistance to understand how to fix the pipeline instead 🙏 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #989 +/- ##
==========================================
- Coverage 59.66% 59.63% -0.04%
==========================================
Files 78 78
Lines 5080 5091 +11
Branches 409 409
==========================================
+ Hits 3031 3036 +5
- Misses 2019 2025 +6
Partials 30 30 ☔ View full report in Codecov by Sentry. |
@@ -94,6 +94,9 @@ export default defineComponent({ | |||
imagesizes: sizes.value.sizes, | |||
imagesrcset: sizes.value.srcset, | |||
}), | |||
...(typeof props.preload !== 'boolean' && props.preload.fetchPriority | |||
? { fetchpriority: props.preload.fetchPriority } | |||
: {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we default to fetchpriority: 'high'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not answering in time, this comment fell off my radar 🌠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still time to update - what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should the fetch priority default to high in your opinion? I'd say we can just leave it for the users to decide if they want to specify any.
@dargmuesli Also, I would like to ask why fetchPriority needs to be placed separately in the preload object? According to my wish, the first setting of the carousel should be set to high as an example
If simply using fetchPriority as an attribute
|
I think I implemented it that way because Nuxt image includes preload link addition to the document's head. Having done a quick research, I think that it's possible to set the |
@dargmuesli
|
Hmm, I'd favor a string as there can be the "enum" values high, low and auto. I see where you're coming from with the true=high suggestion, but that assumes that people understand fetch priority as a tool to increase the priority, but I think people could also want to use it to lower an image's priority. |
Indeed, based on the literal interpretation, fetchPriority should mean to increase or decrease. Asking about design patterns, on the one hand, is for learning and referencing design 😄 |
I'd like to be able to set the fetch priority for preloaded images. This is a quick draft of an implementation. Happy to hear feedback ❤️