Closed
Description
This issue is automatically created based on existing pull request: #39132: Optimize number js
Description (*)
- only execute js with element display in viewport
- only trigger binding with element display in viewport
- add event mousemove for execute for another js
Self test in default magento:
- number of requests reduced 20-30rq when loading page
- Total Blocking Time reduced 20-30ms on Lighthouse
- JavaScript execution time reduced 1s on Lighthouse
For more complex sites, more optimization may be possible.
Related Pull Requests
Fixed Issues (if relevant)
- Fixes magento/magento2#<issue_number>
Manual testing scenarios (*)
- ...
- ...
Questions or comments
Contribution checklist (*)
- Pull request has a meaningful description of its purposeAll commits are accompanied by meaningful commit messagesAll new or changed code is covered with unit/integration tests (if applicable)README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an updateAll automated tests passed successfully (all builds are green)
Activity
m2-assistant commentedon Sep 25, 2024
Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branchDetails
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
Issue: Confirmed
once verification is complete.engcom-Hotel commentedon Sep 25, 2024
Hello @rogerdz,
Thanks for the report and collaboration!
To speed up the processing of this issue, please provide us with the following information:
Thanks
rogerdz commentedon Oct 2, 2024
Hi @engcom-Hotel, I update:
Summary of the issue:
Only execute js with element display in viewport
Only trigger binding with element display in viewport
Add event mousemove for execute for another js
Information on your environment:
magento 2.4-develop
Steps to reproduce:
Open inspect in browser (press f12), select tab network.
Load site without any action same 'touchstart', 'mouseover', 'wheel', 'scroll', 'keydown' actions.
Check the number of requests, only javascript related to the element in viewport is loaded.
Scroll mouse and you will see the remaining javascript loaded.
Check performance in lighthouse
Expected results:
Number of requests reduced 20-30rq when loading page
Total Blocking Time reduced 20-30ms on Lighthouse
JavaScript execution time reduced 1s on Lighthouse
engcom-Hotel commentedon Oct 4, 2024
Hello @rogerdz,
Thanks for the detailed steps!
The issue is not reproducible for us.
We have compared the instances with and without PR changes, but the performance seems degrading. Please have a look at the below screenshots for reference:
Without PR changes:

With PR Changes:

Please let us know if we have missed anything.
Thanks
engcom-Hotel commentedon Oct 21, 2024
Dear @rogerdz,
We've observed that there haven't been any updates on this issue for quite some time. Therefore, we're assuming it's been resolved and will be closing it. Feel free to open a new ticket or reopen this one if you require further assistance.
Regards
4 remaining items
engcom-Hotel commentedon Dec 23, 2024
Hello @rogerdz,
We have retested this issue, please refer to this #39132 (comment).
Thanks
engcom-Bravo commentedon May 5, 2025
Hi @rogerdz,
This issue is being closed since it has not been updated in a long time.Please feel free to reopen or raise a new ticket if the issue still exists.
Thanks.