-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Move JS module initialization to separate tasks #27360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move JS module initialization to separate tasks #27360
Conversation
Hi @krzksz. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
@magento give me test instance |
Hi @krzksz. Thank you for your request. I'm working on Magento instance for you |
@krzksz good catch! |
Hi @lbajsarowicz, thank you for the review.
|
Hi @ptylek, thank you for the review.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @krzksz ,
Amazing improvement!
Could you fix failing static tests?
Pull Request state was updated. Re-review required.
@krzksz do you think it’s possible to cover your changes with some tests? |
Just reviewed test failures - looks like they’re not related to changes from this PR, some failures on MSI. To make sure I just restarted this functional test |
@ihor-sviziev I think I fixed failing static test (there was line break missing) but I don't think this change should be covered by any additional tests. My point is that as long as existing functional tests are passing, it means that all frontend modules are still initialized properly. Otherwise I would have to add tests that are heavily coupled to the implementation which would do more harm then good. |
Static tests failing with |
Hi @ihor-sviziev, thank you for the review. |
@krzksz approved! |
✔️ QA Passed |
Failed functional tests not related to the changes in this PR |
Hi @krzksz, thank you for your contribution! |
@krzksz file: this file is seem to be used by backend |
In theory yes, it's that storefront was my priority because it affects much more people, their experience and actual buying process. |
Description (*)
I'm currently during a process of profilling and trying to improve Magento frontend performance as much as possible. This is one of the improvements that I found.
The Issue
As you can see on the below screenshot


First CPU idle
andMax Potential First Input Delay
times are not great and it would be nice to improve them.And so I run a quick performance profile, with 4x CPU slowdown for easier spotting and here's what I found:
Those two big long-running tasks are coming from Magento initializing all
data-mage-init
modules. The first one is responsible for collecting all the data needed for initialization which happens in the same task as initializing custom Knockout bindings, hence change inlib/web/mage/bootstrap.js
. The second one is initialization of each of the modules themselves which can also be done in separate tasks like you see in changedlib/web/mage/apply/main.js
.The Fix
Here's the result after applying both changes:


As you can see both metrics improved dramatically. Next step would be to reduce this huge
TTI
but until it happens it would be great to make sure we are not blocking the main thread for too long preventing it from handling user interactions.Manual testing scenarios (*)
This is not a functional change, everything should we working as before.
Questions or comments
Since this is not a functional change, as long as all tests are still passing I would consider this change covered with tests.
Contribution checklist (*)