Hello,
I recently took a new position with a fairly large company running their global Marketo instance.
I was recently advised that (non-Marketo) web page load times in certain countries (China, Russia, India) was being impacted by Marketo. Looking at the snippet being used, I was surprised to find the following. Of particular concern was the fact that the instance account ID was not referenced directly. This code is apparently deployed globally. I am at a loss to trouble shoot this myself.
Can anyone offer advice or resources for deciphering this? Again, it appears to be working, even in the impacted countries, it is just causing long load times...
Thanks!
Edward
(function (b) {
if (!b.Munchkin) {
var c = b.document,
e = [],
k, l = {
fallback: "155"
},
g = [null, "156"],
m = function () {
if (!k) {
for (; 0 < e.length;) {
var f = e.shift();
b.MunchkinTracker[f[0]].apply(b.MunchkinTracker, f[1])
}
k = !0
}
},
n = function (f) {
var a = c.createElement("script"),
b = c.getElementsByTagName("base")[0] || c.getElementsByTagName("script")[0];
a.type = "text/javascript";
a.async = !0;
a.src=f;
a.onreadystatechange = function () {
"complete" !== this.readyState && "loaded" !== this.readyState || m()
};
a.onload = m;
b.parentNode.insertBefore(a, b)
},
h = {
ASSOCIATE_LEAD: "ASSOCIATE_LEAD",
CLICK_LINK: "CLICK_LINK",
VISIT_WEB_PAGE: "visitWebPage",
init: function (b) {
var a;
a = l[b];
if (!a && 0 < g.length) {
a = b;
var c = 0,
d;
if (0 !== a.length)
for (d = 0; d < a.length; d += 1) c += a.charCodeAt(d);
a = g[c % g.length]
}
a || (a = l.fallback);
e.push(["init", arguments]);
"150" === a ? n("//munchkin-cdn.marketo.net/" + a + "/munchkin.js") : n("//munchkin.marketo.net/" + a + "/munchkin.js")
}
},
p = function (b) {
return h[b] = function () {
e.push([b, arguments])
}
};
b.mktoMunchkinFunction = p("munchkinFunction");
p("createTrackingCookie");
b.Munchkin = h;
b.mktoMunchkin = h.init
}
})(window);
That is the munchkin init script, except it looks like you're loading it from your own server since the version is still 156.
If you go into admin, look for your munchkin embed code and follow the script url ('//munchkin.marketo.net/munchkin.js '), what you pasted is what you get but version 159
going back to your problem, yes, the init script actually loads another script from marketo ('//munchkin-cdn.marketo.net/159/munchkin.js'), it's probably this one that is lengthening the time for a page to completely finish loading.
Jay,
Thanks for your help. Yes, at the very least, we'll update the version number. But I am also trying to understand why we would be running the script from our server... no one here seems to know the answer. The person who set it up this way is long, long gone... =(
Thanks,
Edward
But I am also trying to understand why we would be running the script from our server...
Almost certainly, it's because they saw that the Munchkin bootstrapper (the first remote script in the embed) in turn loads the full library (the second remote script loaded by the bootstrapper) and thought they were making things more efficient by moving the bootstrapper inline.
But actually they were still blocking.
Script-injected scripts (which is what you have here as the inline <script> is loading a remote <script>) are erroneously thought to be fully asynchronous.
This isn't actually true, as the inline injection it will block load events on the Window.
If you run Munchkin.init itself on Window.load then it won't block:
window.addEventListener("load",function(){
Munchkin.init("aaa-bbb-ccc");
});
Hi Sanford,
So, would we simply preface the existing script with the addEventListener?
Thanks for your help.
Edward
Preface? No, I'm just talking about wrapping Munchkin.init in the listener, not anything else. You aren't showing where you're running Munchkin.init but that's what counts, since it's kicking off the script injection. Before that, it just sits waiting for you to .init.