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_r225511479
 
 

 ##########
 File path: net/instaweb/rewriter/add_instrumentation.js
 ##########
 @@ -88,21 +88,30 @@ pagespeed.AddInstrumentation.prototype.sendBeacon = 
function() {
         timingApi['responseEnd'] - timingApi['responseStart']);
     url += '&dom_c=' + (timingApi['domContentLoadedEventStart'] - 
navStartTime);
 
-    if (window['performance']['navigation']) {
-      url += '&nt=' + window['performance']['navigation']['type'];
+    if (winPerf['navigation']) {
+      url += '&nt=' + winPerf['navigation']['type'];
     }
     var firstPaintTime = -1;
+    var paintEntries, loadTimes;
     if (timingApi['msFirstPaint']) {
       // IE.
       firstPaintTime = timingApi['msFirstPaint'];
-    } else if (window['chrome'] && window['chrome']['loadTimes']) {
+    } else if (winPerf['timeOrigin'] &&
+        winPerf['getEntriesByType'] &&
+        (paintEntries = winPerf['getEntriesByType']('paint')).length > 0) {
+        // Paint Timing API
+        // Note that getEntriesByType('paint') is sorted chronologically
+        firstPaintTime = Math.round(
 
 Review comment:
   can you move the var declaration for firstPaintTime outside the if-block so 
it's obvious that scopes to all the branches?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to