Skip to content

Instantly share code, notes, and snippets.

@bitsmanent
Last active August 22, 2018 17:08
Show Gist options
  • Save bitsmanent/154a5a42c90d67fbdec1 to your computer and use it in GitHub Desktop.
Save bitsmanent/154a5a42c90d67fbdec1 to your computer and use it in GitHub Desktop.
Track XMLHttpRequest (better version here: https://gist.github.com/clamiax/7325ca5c075d954dc61406d7e0cdc7aa)
function trackxhr() {
var xhrsend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
var onready = this.onreadystatechange;
console.log('XHR', 'sending...');
this.onreadystatechange = function() {
if(this.readyState == 4)
console.log('XHR', 'done');
if(onready)
onready.apply(this, arguments);
};
xhrsend.apply(this, arguments);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment