Skip to content

Conversation

dmytromolkov
Copy link

This PR addresses the issue where ttvc is loaded into an SPA after the window.load has fired.

In the current state that means the observer for the resources never registers.

This is already properly handled in the waitForPageLoad called from visuallyCompleteCalculator, we check the document.readyState and immediately resolve if it is complete. But it was not handled for the networkIdleObservable.

I have added the test that validates this behavior. Without the fix it marks ttvc before the img is ever downloaded.

Obviously there is still a gap if the resource started downloading before ttvc was initialized, but at least this way ttvc will work for future SPA navigations. Without this fix any future resources (e.g. additional bundles) are also not tracked.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@ajhyndman ajhyndman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this fix back!

The test looks good and I have verified your solution works. Please sign the CLA so that we can accept your pull request.

Heads up, I also just fixed a lint failure in master, so it may be helpful for you to rebase to resolve that here.

@ajhyndman
Copy link
Member

Also, for the record, and in case anyone else stumbles on this issue: we strongly recommend loading the ttvc library synchronously and as early in the document as possible to ensure accurate stats are reported.

@sfc-gh-dmolkov
Copy link

@ajhyndman sorry, let me go through the steps to be able to contribute to it here from my work account I and will re-do the submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants