Skip to content

Commit fb80caf

Browse files
committed
Track FPP
1 parent 3f22ff8 commit fb80caf

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

_includes/head.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script>performance.mark('headStart');</script>
1+
<script>performance.mark('HEAD_Start');</script>
22
<meta charset=UTF-8>
33
<meta name=viewport content="width=device-width, minimum-scale=1.0">
44

@@ -50,7 +50,7 @@
5050
//# sourceURL=debugbear.inline.js
5151
</script>
5252

53-
<script>performance.mark('cssStart');</script>
53+
<script>performance.mark('CSS_Start');</script>
5454
<style>
5555

5656
{% include css/csswizardry.min.css %}
@@ -63,11 +63,11 @@
6363

6464
</style>
6565
<script>
66-
performance.mark('cssEnd');
66+
performance.mark('CSS_End');
6767

68-
performance.measure('cssTime', {
69-
start: 'cssStart',
70-
end: 'cssEnd',
68+
performance.measure('CSS_Time', {
69+
start: 'CSS_Start',
70+
end: 'CSS_End',
7171
detail: {
7272
devtools: {
7373
dataType: 'track-entry',
@@ -163,11 +163,11 @@
163163
{% endif %}
164164

165165
<script>
166-
performance.mark('headEnd');
166+
performance.mark('HEAD_End');
167167

168-
performance.measure('headTime', {
169-
start: 'headStart',
170-
end: 'headEnd',
168+
performance.measure('HEAD_Time', {
169+
start: 'HEAD_Start',
170+
end: 'HEAD_End',
171171
detail: {
172172
devtools: {
173173
dataType: 'track-entry',

_layouts/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@
102102
//# sourceURL=sw.inline.js
103103
</script>
104104

105-
<script src=/js/obs.speedcurve.js?v=0003 type=module></script>
105+
<script src=/js/obs.speedcurve.js?v=0004 type=module></script>

js/obs.speedcurve.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,15 @@
7272
}
7373
}
7474

75+
/**
76+
* Compute new ‘First Potential Paint’ (FPP) metric. This is the time,
77+
* relative to navigation start, at which the browser finished parsing the
78+
* `<head>` and could potentially start rendering the `<body>`.
79+
*/
80+
const navEntry = performance.getEntriesByType('navigation')[0];
81+
const headEndMark = performance.getEntriesByName('HEAD_End')[0];
82+
const fpp = headEndMark.startTime - navEntry.startTime;
83+
// Assign FPP to a new `measure`.
84+
performance.measure('fpp', { start: navEntry.startTime, end: headEndMark.startTime });
7585

7686
})();

0 commit comments

Comments
 (0)