Is there a way to configure the munchkin client-side library to make page tracking requests asynchronously? | Community
Skip to main content
January 24, 2017
Solved

Is there a way to configure the munchkin client-side library to make page tracking requests asynchronously?

  • January 24, 2017
  • 1 reply
  • 2222 views

We've implemented Munchkin in one of our products however every single click on the page translates to a synchronous request to marketo. This means that if Marketo is ever slow to respond, there is a noticeable delay/freeze as the main thread waits for a response from Marketo. Chrome also warns about this:

munchkin.js:10 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check xhr.spec.whatwg.org/.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Yes, this is a documented Munchkin.init() option:

  Munchkin.init( 'AAA-BBB-CCC', { asyncOnly: true } );

You should be aware that this will drastically (almost comically) decrease accuracy. This is by definition, as an async request is not guaranteed to finish before the page is unloaded and all outstanding foreground connections canceled. Even though Munchkin only requires the HTTP request to complete (the cross-domain HTTP response can't even be processed), the cost of starting up the connection will frequently stop the request from completing.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 24, 2017

Yes, this is a documented Munchkin.init() option:

  Munchkin.init( 'AAA-BBB-CCC', { asyncOnly: true } );

You should be aware that this will drastically (almost comically) decrease accuracy. This is by definition, as an async request is not guaranteed to finish before the page is unloaded and all outstanding foreground connections canceled. Even though Munchkin only requires the HTTP request to complete (the cross-domain HTTP response can't even be processed), the cost of starting up the connection will frequently stop the request from completing.