Created
January 10, 2025 10:02
-
-
Save ceckoslab/9ae08d52a214a1bd1b3035bd78702ede to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
// Navigation Timing | |
// | |
new PerformanceObserver((entryList) => { | |
for (const entry of entryList.getEntries()) { | |
console.log('NavigationTiming:', entry); | |
} | |
}).observe({type: 'navigation', buffered: true}); | |
// 2. | |
// Resource Timing | |
// | |
new PerformanceObserver((entryList) => { | |
for (const entry of entryList.getEntries()) { | |
console.log('Page resource:', entry); | |
} | |
}).observe({type: 'resource', buffered: true}); | |
// 3. | |
// Paint Timing | |
// | |
new PerformanceObserver((entryList) => { | |
for (const entry of entryList.getEntries()) { | |
console.log('Paint timing:', entry); | |
} | |
}).observe({type: 'paint', buffered: true}); | |
// 4. | |
// Layout Shift | |
// | |
new PerformanceObserver((entryList) => { | |
for (const entry of entryList.getEntries()) { | |
console.log('Layout shift:', entry); | |
} | |
}).observe({type: 'layout-shift', buffered: true}); | |
// 5. | |
// Largest Contentful Paint | |
// | |
new PerformanceObserver((entryList) => { | |
for (const entry of entryList.getEntries()) { | |
console.log('LCP candidate:', entry.startTime, entry); | |
} | |
}).observe({type: 'largest-contentful-paint', buffered: true}); | |
// 6. | |
// Visibility State | |
// | |
new PerformanceObserver((entryList) => { | |
for (const entry of entryList.getEntries()) { | |
console.log('Visibility state:', entry); | |
} | |
}).observe({type: 'visibility-state', buffered: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment