You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pagespeed.apache.org by GitBox <gi...@apache.org> on 2018/10/14 13:29:06 UTC
[GitHub] jmarantz commented on a change in pull request #1802: Prefer Paint
Timing API over chrome.loadTimes()
jmarantz commented on a change in pull request #1802: Prefer Paint Timing API over chrome.loadTimes()
URL: https://github.com/apache/incubator-pagespeed-mod/pull/1802#discussion_r224992740
##########
File path: net/instaweb/rewriter/add_instrumentation.js
##########
@@ -95,6 +95,12 @@ pagespeed.AddInstrumentation.prototype.sendBeacon = function() {
if (timingApi['msFirstPaint']) {
// IE.
firstPaintTime = timingApi['msFirstPaint'];
+ } else if (window['performance']['timeOrigin'] &&
+ window['performance']['getEntriesByName']('first-paint').length > 0) {
+ // Paint Timing API
+ firstPaintTime = Math.floor(
+ window.performance.timeOrigin +
+ window.performance.getEntriesByName('first-paint')[0].startTime);
Review comment:
I'm a bit OCD when it comes to CSE :) WDYT of making a temp `winPerf` for window['performance'] and then using it afterward, and likeways for winPerf['getEntriesByName'] and others where you test first and then call, or have chains of dereferencing...
This is just a suggestion, and it would require something like a nested helper function to help you manage the temps in the conditional.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services