Mouseflow Asynchronous Script

I’ve noticed that, among all the tracking pixels things, that Mouseflow tends to slow pages down to a crawl quite often.

Recently encountering this on a client’s website, I took a look at the way Mouseflow suggested you embed their code, and therein lies the problem:

<script type="text/javascript">
document.write(unescape("%3Cscript src='" + (("https:" == document.location.protocol) ? "https" : "http") + "://' type='text/javascript'%3E%3C/script%3E"));

Rather ugly, right?

So, patterning after Google Analytics’s asynchronous script, voila — non-blocking, stripped down version of Mouseflow analytics script:

<script type="text/javascript">
(function(d) {
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//';
var t = d.getElementsByTagName('script')[0]; 
t.parentNode.insertBefore(s, t);
})(document); </script>

2 thoughts on “Mouseflow Asynchronous Script

  1. Hi,

    Thanks a bunch for pointing this out. As a matter of fact we recently phased out the old tracking code and replaced it with an asynchronous one. We’ve also improved out backend service to provide faster data transfer.

    The new tracking code looks like this:

    (function() {
    var mf = document.createElement(“script”); mf.type = “text/javascript”; mf.async = true;
    mf.src = “//{project-id}.js”;

Leave a Reply

Your email address will not be published. Required fields are marked *