Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Marketo Munchkin synchronous requests hurt JS performance

Recently I noticed some performance issues in my site's javascript code. After some profiling I discovered that the problem is the Marketo Munchking code I use to track events. It looks like lately they changed their JS code to send synchronous http request for every call to Munchkin.munchkinFunction. The relevant code snippet is:

a=new XMLHttpRequest;a.open("GET",b,!1); ... a.send();

I've opened a ticket with Marketo, but until they fix their code, I'm looking for a workaround. I thought of a few:

  1. Is there a way to hook their js code to force the XMLHttpRequest to be async?
  2. It is safe to reference directly to older versions of their script, for example //munchkin.marketo.net/143/munchkin.js. I tested it and it works but maybe I'm missing something.

Are there any more workarounds? Any thought is appreciated.

UPDATE:

Just got a response from Marketo support. They admit that the calls are indeed synchronous, but they claim that this is the only way not to lose information. I guess they think of the case when a call to Munchkin.munchkinFunction is made just before a redirect. I disagree with them, and will ask them to provide an alternative. In the mean time I'm using an old version of their code.

UPDATE #2:

Got another response from their support team that said my ideas are good, but they can't implement them right now, and they hope that one of the developers will pick them up someday... Anyway I've created an idea in the Marketo community.

like image 468
Tzach Avatar asked Sep 11 '14 11:09

Tzach


1 Answers

Update (Oct 2015): this feature is now documented here.

I just went over the new version of the Munchkin code (150) and found the following undocumented parameter:

Munchkin.init('XXXXXX', {asyncOnly: true});

I tried it and it does the job - all the HTTP requests are now async.

like image 172
Tzach Avatar answered Sep 25 '22 03:09

Tzach