elementor icon indicating copy to clipboard operation
elementor copied to clipboard

Add Optimization Detective experiment

Open westonruter opened this issue 1 year ago • 4 comments
trafficstars

PR Checklist

  • [x] The commit message follows our guidelines: https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [x] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Documentation content changes
  • [ ] Other... Please describe:

Summary

This PR can be summarized in the following changelog entry:

  • Add Optimization Detective experiment to leverage real user metrics to optimize the loading of images and embeds.

Description

An explanation of what is done in this PR

Test instructions

This PR can be tested by following these steps:

  1. Activate the Optimization Detective experiment.
  2. Log out, since Optimization Detective only optimizes pages for non-admins.
  3. Navigate to a page that has one or more IMG elements.
  4. While scrolled to the top of the page, reload in desktop, tablet, and mobile viewport sizes over the course of a few minutes. (By default, storage of new URL metrics locked once per minute for a given IP.)
  5. The loading of the images should now be optimized, with fetchpriority=high and loading=lazy added to the correct IMG elements. Note also that a preload link with fetchpriority=high will be added with the appropriate media query. (Only if an IMG is the LCP element across all viewport sizes will it get the fetchpriority=high attribute.) The loading of Embeds should be similarly optimized, with embeds out of the initial viewport being lazy-loaded.

Quality assurance

  • [x] I have tested this code to the best of my abilities
  • [ ] I have added unittests to verify the code works as intended
  • [ ] Docs have been added / updated (for bug fixes / features)

westonruter avatar Sep 29 '24 23:09 westonruter

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 29 '24 23:09 CLAassistant

cc @shilo-ey, @adamsilverstein

westonruter avatar Sep 29 '24 23:09 westonruter

@westonruter If I understand correctly, this PR implements an experiment that downloads Optimization detective.

Wouldn't it be better to include it as part of the plugin's code as a library that can be turned on/off?

Thank you!

shilo-ey avatar Oct 06 '24 08:10 shilo-ey

@shilo-ey actually the intention is that the plugins are downloaded and bundled with the plugin. It's using Composer to do the downloading so that the plugin source files don't have to be committed to the repo.

westonruter avatar Oct 07 '24 02:10 westonruter