Last active
January 23, 2019 01:46
-
-
Save surfmuggle/e43bd2b9c5a669948ffdaf6074be71cb to your computer and use it in GitHub Desktop.
Firefox Extension - why does it log page.renderTime -1548207097891 instead of something like = 885
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.onreadystatechange = function () { | |
console.log("content script was fired onreadystatechange "); | |
class PageMeasurement { | |
constructor(url) { | |
this.url = url; | |
this.date = Date.now(); | |
var t = window.performance.timing; | |
this.pageLoadTime = (t.loadEventEnd - t.fetchStart); | |
this.renderTime = (t.loadEventEnd - t.responseEnd); | |
} | |
} | |
if (document.readyState === 'complete') { | |
console.log("document.readyState === complete") | |
var page = new PageMeasurement(document.URL); | |
console.log("page.renderTime", page.renderTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If i paste the class below into the console directly it returns the correct render time. As part of my extension (see above) it does not. Why is this the case?