Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 503f9d5

Browse filesBrowse files
author
Josh Appel
committed
ups
1 parent 8c0904c commit 503f9d5
Copy full SHA for 503f9d5

File tree

Expand file treeCollapse file tree

1 file changed

+47
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+47
-0
lines changed

‎SNIPPETS.md

Copy file name to clipboardExpand all lines: SNIPPETS.md
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ https://github.com/nucliweb/webperf-snippets/assets/1307927/2987a2ca-3eef-4b73-8
5353
- [Inline CSS Info and Size](#inline-css-info-and-size)
5454
- [Get your `<head>` in order](#get-your-head-in-order)
5555
- [e.g. web.dev](#eg-webdev)
56+
- [Event Processing Time](#event-processing-time)
5657
- [Interaction](#interaction)
5758
- [Long Task](#long-task)
5859
- [Layout Shifts](#layout-shifts)
@@ -787,6 +788,52 @@ Use [capo.js](https://github.com/rviscomi/capo.js) the [Rick Viscomi](https://gi
787788
788789
<img width="842" alt="image" src="https://github.com/rviscomi/capo.js/assets/1120896/fe6bb67c-697a-4fdf-aa28-52429239fcf5">
789790
791+
792+
### Event Processing Time
793+
794+
Find the process time it took for events to finish.
795+
796+
```javascript
797+
798+
// list events of to calculate processing time
799+
800+
const events = new Map([
801+
["connectTime", { start: "connectStart", end: "connectEnd" }],
802+
["domainLookupTime", { start: "domainLookupStart", end: "domainLookupEnd" }],
803+
[
804+
"DOMContentLoaded",
805+
{ start: "domContentLoadedEventStart", end: "domContentLoadedEventEnd" }
806+
],
807+
808+
["onload", { start: "loadEventStart", end: "loadEventEnd" }]
809+
]);
810+
811+
const observer = new PerformanceObserver((list) => {
812+
const displayTimes = [];
813+
list.getEntries().forEach((entry) => {
814+
console.log(entry);
815+
for (const [key, value] of events) {
816+
const endValue = entry[value.end];
817+
const startValue = entry[value.start];
818+
819+
const eventTime = endValue - startValue;
820+
821+
displayTimes.push({
822+
url: entry.name,
823+
event: key,
824+
processingTime: `${eventTime.toFixed(2)} ms`
825+
});
826+
}
827+
});
828+
829+
console.table(displayTimes);
830+
});
831+
832+
observer.observe({ type: "navigation", buffered: true });
833+
834+
```
835+
836+
790837
## Interaction
791838
792839
### Long Task

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.