elementor
elementor copied to clipboard
Add Optimization Detective experiment
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
- Create a new Optimization Detective experiment which embeds the Optimization Detective plugin as well as the Image Prioritizer and Embed Optimizer plugins from Performance Lab. Also installed, but not yet included, is the WIP plugin Elementor LCP Background Image Preloader (which needs an Elementor engineer to assist with completing). These plugins are downloaded via Composer by means of civicrm/composer-downloads-plugin.
Test instructions
This PR can be tested by following these steps:
- Activate the Optimization Detective experiment.
- Log out, since Optimization Detective only optimizes pages for non-admins.
- Navigate to a page that has one or more
IMGelements. - 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.)
- The loading of the images should now be optimized, with
fetchpriority=highandloading=lazyadded to the correctIMGelements. Note also that a preload link withfetchpriority=highwill be added with the appropriate media query. (Only if anIMGis the LCP element across all viewport sizes will it get thefetchpriority=highattribute.) 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)
cc @shilo-ey, @adamsilverstein
@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 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.