wp-rocket
wp-rocket copied to clipboard
Background cpu#6408
Description
Refactore the regex pattern for css background lazyloading and improve it to be more faster. Fixes #6408
Documentation
User documentation
Explain how this code impacts users.
Technical documentation
Explain how this code works. Diagram & drawings are welcomed.
Type of change
- [x] Enhancement (non-breaking change which improves an existing functionality).
New dependencies
N/A
Risks
List possible performance & security issues or risks, and explain how they have been mitigated.
Checklists
Feature validation
- [x] I validated all the Acceptance Criteria. If possible, provide sreenshots or videos.
- [x] I triggered all changed lines of code at least once without new errors/warnings/notices.
- [x] I implemented built-in tests to cover the new/changed code.
Documentation
- [ ] I prepared the user documentation for the feature/enhancement and shared it in the PR or the GitHub issue.
- [ ] The user documentation covers new/changed entry points (endpoints, WP hooks, configuration files, ...).
- [ ] I prepared the technical documentation if needed, and shared it in the PR or the GitHub issue.
Code style
- [x] I wrote self-explanatory code about what it does.
- [x] I wrote comments to explain why it does it.
- [x] I named variables and functions explicitely.
- [x] I protected entry points against unexpected inputs.
- [x] I did not introduce unecessary complexity.
- [ ] I listed the introduced external dependencies explicitely on the PR.
- [ ] I validated the repo-specific guidelines from CONTRIBUTING.md.
Observability
- [ ] I handled errors when needed.
- [ ] I wrote user-facing messages that are understandable and provide actionable feedbacks.
- [ ] I prepared ways to observe the implemented system (logs, data, etc.).
Risks
- [ ] I explicitely mentioned performance risks in the PR.
- [ ] I explicitely mentioned security risks in the PR.
Test plan:
1- Run LLBG tests on e2e npm run test:llcssbg
=> confirms it' passing, if not recheck failed test manually to see if it passes
2- Performance check => running the scenario mentioned here on gamma n times on branch and trunk (compare results)
3- Run related test run https://wpmediaqa.testrail.io/index.php?/runs/view/821&group_by=cases:section_id&group_order=asc
4- Some exploratory test with different themes + page builder
Why did u update dependencies on this PR?
No dependencies was updated, maybe an oversight
Why did u update dependencies on this PR?
Fixed this
@wordpressfan It seems this PR is pending for your updated review, following your request for changes. Can you have a quick look? Thanks 🙏
About the byte vs. number of characters mentionend by @wordpressfan : Hmm interesting but I think that won't be an issue because all methods we use around the PREG_OFFSET_CAPTURE are working with byte: preg_match_all returns the offset as bytes. Then we do some operations on the original_offset with strlen which also works with bytes. Then we use that value in the next preg_match which expects bytes too.