swissspidy / media-experiments

WordPress media experiments
GNU General Public License v2.0
69 stars 1 forks source link

Optimizing the whole media library #245

Open swissspidy opened 7 months ago

swissspidy commented 7 months ago

Like other plugins this plugin could offer a separate page to allow optimizing the whole media library.

Loop through all media items client-side, skip the ones that are already optimized, and then optimize images and videos

Implementation-wise it could be relatively simple:

Caveats:

swissspidy commented 5 months ago

Some additional notes based on an earlier conversation with @westonruter:

Service worker might be tricky, see https://chromium.googlesource.com/chromium/src/+/main/docs/security/service-worker-security-faq.md#do-service-workers-live-forever

"Chrome also detects long-running workers and terminates them. It does this if an event takes more than 5 minutes to settle, or if the worker is busy running synchronous JavaScript and does not respond to a ping within 30 seconds."

Periodic background sync API likely not suitable either.

It's only available if you installed the PWA to the homescreen and if the site engagement score is high enough

Background fetch API sounds interesting, but more aimed towards downloads

swissspidy commented 1 month ago

Maybe could do a POC with Workbox / the PWA plugin. See https://github.com/GoogleChromeLabs/pwa-wp/wiki/Service-Worker