Access XMLHttpRequest from Ember Data


#1

I am developing a web application in Ember 2.3.0 and while doing some cross-browser testing, it became apparent the slowness of the application for IE 11. Doing some measurements on the IE developer’s console seems that the DOM onreadystatechange event eats up to 100% CPU for a period of time, which could be a leak.

I found this article: http://milan.adamovsky.com/2012/02/javascript-memory-leaks-in-internet.html that despite being old it encouraged me to test the approach of nulling the onreadystatechange event in case it is a memory leak.

var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function () {
  if (ajax.readyState === 4) {
    // code on completionPreformatted text

    ajax.onreadystatechange = CollectGarbage;
    ajax = null;
  }
};

But in Ember I don’t know how to access the XMLHttpRequest object directly. The JSONApiAdapter provides with an ajax method to rewrite but I don’t see how I can access the raw object:

const Adapter = DS.JSONAPIAdapter.extend({
  ajax: function(){ ... }
})