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

Split out image-specific aspects of Optimization Detective to dependent plugin #1088

Open
westonruter opened this issue Mar 25, 2024 · 6 comments · May be fixed by #1172
Open

Split out image-specific aspects of Optimization Detective to dependent plugin #1088

westonruter opened this issue Mar 25, 2024 · 6 comments · May be fixed by #1172
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@westonruter
Copy link
Member

Feature Description

As discussed at depth in #1046, Optimization Detective is to be an infrastructure/framework/API dependency plugin which isn't promoted directly to end-users. Instead, a dependent plugin like "Image Loading Optimization" (or perhaps "Image Prioritizer") would be developed which extends Optimization Detective with the image-related aspects.

To do this, we will need to ensure that Optimization Detective exposes an API that allows dependent plugins to hook into the detection and optimization process. For detection, I'm assuming this looks like a PHP filter that allows additional tags to be targeted for visiting by the tag processor. And then for optimization, this could look like an action that fires at each such tag which is visited.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Optimization Detective Issues for the Optimization Detective plugin labels Mar 25, 2024
@joemcgill
Copy link
Member

I like this idea, but wonder what the scope of a new Image Loading Optimization plugin would include and whether using client side data from the Optimization Detective Framework would be an optional feature of this type of plugin or if it would be a base requirement. For example, I could see a plugin that includes some of all of these options:

  • Serve modern image formats (e.g., WebP, AVIF, etc.)
  • Improve responsive image handling (e.g., auto-sizes, calculation improvements, srcset generation enhancements, etc.)
  • Improve resource loading: (fetch-priority, lazy-loading, etc)
  • CDN integration
  • Use client side optimization enhancements

Alternatively, I could see some confusion if we had a standalone plugin for Image Loading Optimization, which was only optimizations built using the Optimizations Detective API but also had individual feature plugins for things like auto-sizes, sizes calculation ehancements, webp, etc. that were not based on the new API.

@felixarntz
Copy link
Member

felixarntz commented Apr 2, 2024

@joemcgill The scope of the "Image Loading Optimization" (which now may be renamed to "Image Prioritizer") would be the same as what Optimization Detective currently includes as a proof of concept: It's focused on applying fetchpriority="high" and loading="lazy" correctly. Any other image related features should be in separate plugins, such as for instead modern image formats being part of the "Modern Image Formats" plugin (formerly "WebP Uploads").

In other words, the image loading optimization plugin would have "Optimization Detective" as a dependency (i.e. required), since without it all it could do is enhance the limited server-side heuristics that core already comes with.

@felixarntz
Copy link
Member

@westonruter I think a good approach to refine the API to be flexible enough for their potential use-cases is to think through the additional ideas that the client-side detection could be used for. I believe you had mentioned several such ideas somewhere, so maybe we can aggregate them here and then work through them to define an API specification that would cover all of them (and hopefully similar other use-cases).

@joemcgill
Copy link
Member

Thanks for clarifying @felixarntz. I also think the proposed new name is much more clear and limits the scope to just when an image is requested and not other optimizations like file format or responsive image strategies.

@westonruter
Copy link
Member Author

westonruter commented Apr 3, 2024

As for the use cases. Image Prioritizer scope I think includes:

Outside Image Prioritizer:

The extensibility should allow:

  1. Customizing which elements are in scope for detection and optimization (currently only img tags and elements with inline background images are measured).
  2. Extending the URL Metrics schema with additional metrics.
  3. Injecting additional JavaScript code into the detection process to amend the submitted URL Metric. (PHP API can allow passing a list of JS module URLs which then get dynamically imported in the detect() function. Each JS module would follow common interface.)

@felixarntz
Copy link
Member

@westonruter I agree with your list, except for:

Improve sizes attribute based on client-side measurements (when not adding auto).

That IMO isn't related to prioritizing images and therefore should be in its own plugin that could depend on Optimization Detective. In fact, @joemcgill is exploring such optimization already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants