-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Warning about bad formats order or maybe some reordering of outputs object? #71
Comments
Here’s a rule list I think would be useful:
Are there others? |
Hey, hope it's cool to chime in. My only concern with a warning would be that it might get lost in the output/people might not notice it easily. Is throwing an error too heavy-handed? Might make sense to auto-sort the formats to prioritize webp/avif as a best practice. |
Ah @AleksandrHovhannisyan I do think we should auto-sort for those small set of rules (paired with an opt-out) but also show a warning that a re-sort happened? |
Yup, that makes sense! |
@zachleat Are you accepting PRs for this enhancement? I'd be happy to contribute one if you think the scope is manageable, and unless you'd prefer to tackle it yourself. Haven't dived back into the code yet, but I'm thinking it should be simple. We can have a map from extensions to numeric priorities and then use it to sort the formats array. Is there already a standard way of communicating warnings in the plugin? |
If you use
formats: ["jpeg", "webp", "avif"]
thegenerateHTML
utility will generate markup with<source>
in the wrong order.There is some intentional behavior there that we wouldn’t want to destroy, maybe you’d want
"jpeg", "png"
or"png", "webp"
. At this point in time "avif" should never be last though. And it’s very unlikely "webp" would come after "jpeg" or "png". I doubt you’d want "webp" before "avif" too.So, not sure. I think warnings are in order so that we can lean towards teaching instead of using automation to protect from requiring the knowledge.
The text was updated successfully, but these errors were encountered: