Skip to content
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

reactOnRailsPageLoaded invoked before deferred scripts are completed #1150

Closed
rakelley opened this issue Sep 27, 2018 · 4 comments
Closed

reactOnRailsPageLoaded invoked before deferred scripts are completed #1150

rakelley opened this issue Sep 27, 2018 · 4 comments
Labels

Comments

@rakelley
Copy link
Contributor

When Turbolinks is disabled, clientStartup.js can invoke reactOnRailsPageLoaded in a manner that appears premature and unintentional (and is causing my team no end to grief).

The offending code is the timeout declared here with the condition if (document.readyState === 'complete' || document.readyState !== 'loading' && !document.documentElement.doScroll) {. A readyState of interactive while deferred scripts are still being processed will lead to reactOnRailsPageLoaded being called before all components have been registered. From our testing, Chrome seems to be the only browser fast enough to actually trigger this behavior, but it's a serious issue for us, made worse if utilizing preloading/server-push.

By the surrounding debug messages and the choice to use DOMContentLoaded event handlers, the intention seems to be that reactOnRailsPageLoaded should not be invoked until the page is actually loaded, which is not merely readyState = interactive but post-DOMContentLoaded.

Is it intentional that reactOnRailsPageLoaded is called before DOMContentLoaded, if any only if Turbolinks is disabled?

@justin808
Copy link
Member

@rakelley I'm open to a PR for this. I can push a beta version for you.

Is it intentional that reactOnRailsPageLoaded is called before DOMContentLoaded, if any only if Turbolinks is disabled?

Certainly not. I really cannot recollect this logic. It's been this way for years.

@justin808
Copy link
Member

@rakelley please email me justin@shakacode.com and we can probably work this out pretty quickly.

@justin808
Copy link
Member

Shipped in 11.0.6.

@rakelley can you confirm that it works as expected?

@rakelley
Copy link
Contributor Author

rakelley commented Oct 9, 2018

@justin808 Yes, 11.0.6 is working for us in all scenarios, thank you for the quick turn-around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants