Skip to content

Commit bbdba01

Browse files
author
Paul Boocock
committed
Fix race condition when using Form and Link Click tracking (close #962)
1 parent 1ce5bc9 commit bbdba01

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/js/snowplow.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ export function Snowplow(asynchronousQueue, functionName) {
247247

248248
// initialize the Snowplow singleton
249249
addEventListener(windowAlias, 'beforeunload', beforeUnloadHandler, false);
250-
addReadyListener();
250+
if (document.readyState === 'loading') {
251+
addReadyListener();
252+
} else {
253+
loadHandler();
254+
}
251255

252256
// Now replace initialization array with queue manager object
253257
return new InQueueManager(Tracker, version, mutSnowplowState, asynchronousQueue, functionName);

0 commit comments

Comments
 (0)