| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 20b8616 commit f5035a7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ const go = () => { | |||
| 22 | 22 | const bootStandard = require('bootstraps/standard/main'); | |
| 23 | 23 | const config = require('lib/config'); | |
| 24 | 24 | const { markTime } = require('lib/user-timing'); | |
| 25 | - const capturePerfTimings = require('lib/capture-perf-timings'); | ||
| 25 | + const { capturePerfTimings } = require('lib/capture-perf-timings'); | ||
| 26 | 26 | ||
| 27 | 27 | domready(() => { | |
| 28 | 28 | // 1. boot standard, always | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,11 @@ | |||
| 1 | + // @flow | ||
| 1 | 2 | import ophan from 'ophan/ng'; | |
| 2 | - import userTiming from 'lib/user-timing'; | ||
| 3 | + import { getMarkTime } from 'lib/user-timing'; | ||
| 3 | 4 | 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; | ||
| 7 | 9 | ||
| 8 | 10 | if (!supportsPerformanceProperties) { | |
| 9 | 11 | return; | |
@@ -16,24 +18,27 @@ export default function captureTiming() { | |||
| 16 | 18 | 'commercial request', | |
| 17 | 19 | 'commercial boot', | |
| 18 | 20 | 'enhanced request', | |
| 19 | - 'enhanced boot' | ||
| 21 | + 'enhanced boot', | ||
| 20 | 22 | ]; | |
| 21 | 23 | const performance = { | |
| 22 | 24 | dns: timing.domainLookupEnd - timing.domainLookupStart, | |
| 23 | 25 | connection: timing.connectEnd - timing.connectStart, | |
| 24 | 26 | firstByte: timing.responseStart - timing.connectEnd, | |
| 25 | 27 | lastByte: timing.responseEnd - timing.responseStart, | |
| 26 | - domContentLoadedEvent: timing.domContentLoadedEventStart - timing.responseEnd, | ||
| 28 | + domContentLoadedEvent: timing.domContentLoadedEventStart - | ||
| 29 | + timing.responseEnd, | ||
| 27 | 30 | loadEvent: timing.loadEventStart - timing.domContentLoadedEventStart, | |
| 28 | 31 | navType: performanceAPI.navigation.type, | |
| 29 | 32 | redirectCount: performanceAPI.navigation.redirectCount, | |
| 30 | 33 | assetsPerformance: marks.map(mark => ({ | |
| 31 | 34 | name: mark, | |
| 32 | - timing: parseInt(userTiming.getMarkTime(mark) || 0, 10) | ||
| 35 | + timing: parseInt(getMarkTime(mark) || 0, 10), | ||
| 33 | 36 | })), | |
| 34 | 37 | }; | |
| 35 | 38 | ||
| 36 | 39 | ophan.record({ | |
| 37 | - performance | ||
| 40 | + performance, | ||
| 38 | 41 | }); | |
| 39 | - } | ||
| 42 | + }; | ||
| 43 | + | ||
| 44 | + export { capturePerfTimings }; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments