Edge performance during document open/write/close worse than older IE / Chrome

Confirmed Issue #15194745 • Assigned to Travis L.


Nic J.
Dec 22, 2017
This issue is public.
Found in
  • Microsoft Edge
  • Internet Explorer
Found in build #
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

CC Todd Reifsteck

As part of a performance review of Boomerang, we’ve been doing an audit of all aspects of its impact on host pages. This includes the “loader snippet” we encourage Boomerang users to use to load Boomerang.

The loader snippet goes something like this:

  var dom,doc,where,iframe = document.createElement('iframe');
  iframe.src = "javascript:void(0)";
  (iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0";
  var where = document.getElementsByTagName('script')[0];
  where.parentNode.insertBefore(iframe, where);

  try {
    doc = iframe.contentWindow.document;
  } catch(e) {
    dom = document.domain;
    iframe.src="javascript:var d=document.open();d.domain='"+dom+"';void(0);";
    doc = iframe.contentWindow.document;
  doc.open()._l = function() {
    var js = this.createElement("script");
    if(dom) this.domain = dom;
    js.id = "boomr-if-as";
    js.src = 'http://your-cdn.host.com/path/to/boomerang-<version>.js';
  doc.write('<body onload="document._l();">');

In general, we find that most browsers on modern machines can execute the above code in under 10 milliseconds (as measured by developer tools profiling and/or performance.now()).

Mobile devices are a bit slower, sometimes taking ~30 milliseconds to execute the above snippet.

However, we’re seeing significantly worse performance cost in Edge. In fact, performance with the above snippet is fine in IE 10, and got worse afterwards:

  • IE 10: 12ms
  • IE 11: 46ms
  • Edge 41: 66ms

We’ve narrowed the cost down to the document.open/write/close. Without those lines, the snippet only takes 4ms to execute in Edge.

We realize this snippet isn’t the “standard” way most people use to load JavaScript, but it is the only known way to load a third-party script that won’t affect the host page’s onload time.

We’ll be investigating other ways of potentially reducing the snippet’s overhead in Edge, but we are curious as to why it is so costly and if there’s anything else we could do.


0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “travil”

      Changed Status to “Confirmed”

      Changed Status from “Confirmed”

      Changed Status to “Confirmed”

      Changed Assigned To from “travil” to “Travis L.”

    You need to sign in to your Microsoft account to add a comment.

    Sign in