FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

convert capturePerfTimings to es6 and add flow · devhttps/frontend@f5035a7 · GitHub

Commit f5035a7

Browse files
Calum Campbell
committed
convert capturePerfTimings to es6 and add flow
1 parent 20b8616 commit f5035a7

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎static/src/javascripts/boot.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const go = () => {
2222
const bootStandard = require('bootstraps/standard/main');
2323
const config = require('lib/config');
2424
const { markTime } = require('lib/user-timing');
25-
const capturePerfTimings = require('lib/capture-perf-timings');
25+
const { capturePerfTimings } = require('lib/capture-perf-timings');
2626

2727
domready(() => {
2828
// 1. boot standard, always
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// @flow
12
import ophan from 'ophan/ng';
2-
import userTiming from 'lib/user-timing';
3+
import { getMarkTime } from 'lib/user-timing';
34
import performanceAPI from 'lib/window-performance';
4-
export default function captureTiming() {
5-
const supportsPerformanceProperties = 'navigation' in performanceAPI &&
6-
'timing' in performanceAPI;
5+
6+
const capturePerfTimings = (): void => {
7+
const supportsPerformanceProperties =
8+
'navigation' in performanceAPI && 'timing' in performanceAPI;
79

810
if (!supportsPerformanceProperties) {
911
return;
@@ -16,24 +18,27 @@ export default function captureTiming() {
1618
'commercial request',
1719
'commercial boot',
1820
'enhanced request',
19-
'enhanced boot'
21+
'enhanced boot',
2022
];
2123
const performance = {
2224
dns: timing.domainLookupEnd - timing.domainLookupStart,
2325
connection: timing.connectEnd - timing.connectStart,
2426
firstByte: timing.responseStart - timing.connectEnd,
2527
lastByte: timing.responseEnd - timing.responseStart,
26-
domContentLoadedEvent: timing.domContentLoadedEventStart - timing.responseEnd,
28+
domContentLoadedEvent: timing.domContentLoadedEventStart -
29+
timing.responseEnd,
2730
loadEvent: timing.loadEventStart - timing.domContentLoadedEventStart,
2831
navType: performanceAPI.navigation.type,
2932
redirectCount: performanceAPI.navigation.redirectCount,
3033
assetsPerformance: marks.map(mark => ({
3134
name: mark,
32-
timing: parseInt(userTiming.getMarkTime(mark) || 0, 10)
35+
timing: parseInt(getMarkTime(mark) || 0, 10),
3336
})),
3437
};
3538

3639
ophan.record({
37-
performance
40+
performance,
3841
});
39-
}
42+
};
43+
44+
export { capturePerfTimings };

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL