Skip to content
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

Enable <picture> element & convert to multiple formats #1

Open
holdit opened this issue Jun 8, 2021 · 3 comments
Open

Enable <picture> element & convert to multiple formats #1

holdit opened this issue Jun 8, 2021 · 3 comments

Comments

@holdit
Copy link

holdit commented Jun 8, 2021

It would be nice if it was possible to convert to multiple formats and then use the <picture> element to make them all available.

This would remove the need to use a polyfill for WebP (it's not only IE, but Safari too - they only added support recently), AVIF, and other formats. Smaller website operators already have difficulties meeting Google PageSpeed requirements (Lighthouse 8.0 is even stricter), so more js files is not what they need.

It would also make it easier for WordPress to adopt newer formats. WebP was released ~10 years ago... will we have to wait another 10 years for AVIF? With <picture> we can have WebP and/or AVIF and a JPG/PNG/GIF fallback.

As for downsides, I can think of 3:

  • It uses more storage.
  • Upload can be slow if conversion happens right away.
  • It will use more CPU.

For the disk space, I don't think this is a huge issue as even shared hosting plans come with a lot of space these days.

Regarding upload speeds, processing could happen in the background for some formats. For example, if it's slow to convert to AVIF, WordPress could generate a WebP copy first and then convert AVIF later on. If a AVIF file is uploaded, then conversion could happen in real time. (Plugins like EWWW Image Optimizer support this and it's useful when we're uploading multiple files or are on slow servers.)

CPU usage... well, not sure if there's much that can be done here.

Maybe this shouldn't the default behaviour, but I think it would be useful if WordPress supported this.

@adamsilverstein
Copy link
Owner

Hi @holdit! Thanks for opening this issue.

I agree with almost everything you say and reached somewhat of the same conclusion about the CPU usage. Unfortunately, CPU resource contention is a huge issue, especially for hosts that have many sites on "shared" resources. So you are probably right that this couldn't be a default for WordPress.

This repo would be a great place to experiment with that feature. Have you seen this nifty web app that helps you build the picture element? https://just-gimme-an-img.vercel.app/

@luc122c
Copy link

luc122c commented Jun 17, 2021

Regarding the CPU usage, could you delay the creation of optimised versions of images to a time of less traffic? Perhaps hooking into wp-cron?

@adamsilverstein
Copy link
Owner

Regarding the CPU usage, could you delay the creation of optimised versions of images to a time of less traffic? Perhaps hooking into wp-cron?

@luc122c - Right, WordPress would handle this fine, the issue remains though - overall we would be doubling the number of images generated, increasing load on servers (especially for hosts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants