-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
requirejs/domReady.js can severely delay rendering of content #22909
Comments
Hi @DrewML. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. @DrewML do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
Looks like it enough to change magento2/lib/web/requirejs/domReady.js Line 92 in 211dd25
I don't see any other different compare to https://github.com/jquery/jquery/blob/master/src/core/ready.js |
@kandy Pretty much! |
@dmanners Thank you for verifying the issue. Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
Once all required information is added, please add label |
@dmanners Thank you for verifying the issue. Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
Once all required information is added, please add label |
✅ Confirmed by @dmanners Issue Available: @dmanners, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Hi @johnhughes1984. Thank you for working on this issue.
|
This issue wasn't fixed yet, so re-opened |
@ihor-sviziev Thank you for verifying the issue. Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
Once all required information is added, please add label |
✅ Confirmed by @ihor-sviziev Issue Available: @ihor-sviziev, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Hi @ihor-sviziev. Thank you for working on this issue.
|
Hi @DrewML, @johnhughes1984. Thank you for your report and collaboration! The issue was fixed by Magento team. The fix was delivered into The fix will be available with the upcoming |
Closing as fixed via #23313 |
Preconditions (*)
requirejs/domReady.js
to render some content on the page. As an example, the Private Content feature of Magento works this way, so a default Luma setup is ready to go.I haven't tested, but I assume this problem does not exist if bundling has been used. When bundling,
domReady.js
will be in a bundle loaded synchronously, soDOMContentLoaded
will always fire after.Steps to reproduce (*)
<img src="https://httpstat.us/404?sleep=10000" />
can be used for testing. This is done to simulate real-world delays that can happen with 3rd party contentNote that, after refreshing the page several times, sometimes (race condition) the private content does not render until 10+ seconds have passed.
Expected result (*)
I expect
domReady.js
to invoke its registered handlers at either of the following times (whichever is observed first):DOMContentLoaded
event is fired on thedocument
document.readyState !== 'loading'
The problem right now is that, if
domReady.js
loads/executes after theDOMContentLoaded
event has been fired on thedocument
, the code falls back to waiting for theload
event. This is bad, and was a hack for older versions of IE to avoid doing browser sniffing.We should basically borrow jQuery's implementation of this, as we know it's supported by all our target browsers. We should not import
jQuery
intodomReady.js
, though. Just copy/paste the implementation (few LOC).Actual result (*)
If
domReady.js
loads and executes afterDOMContentLoaded
has already fired, registered handlers will not be invoked until every pending request for a resource has completed. This includes requests for non-critical, 3rd party resources.Example
What scripts/content get delayed currently by this?
x-magento-init
ordata-mage-init
widgets (becausemage/bootstrap.js
depends on KnockoutJS, which waits with thedomReady!
plugin)Additional Info
This problem is still present in the latest version of requirejs/domReady, to support browsers that Magento does not support.
As
requirejs/domReady.js
is from an older library that really doesn't change much, and is a small amount of code, I'm comfortable with us basically forking thedomReady
loader here and changing the logic inline.The text was updated successfully, but these errors were encountered: