ttvc icon indicating copy to clipboard operation
ttvc copied to clipboard

Fix for async loading of TTVC lib

Open dmytromolkov opened this issue 5 months ago • 3 comments

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.

dmytromolkov avatar Sep 17 '25 23:09 dmytromolkov