Skip to content

Commit

Permalink
feat: cwv-ttfb is measured manually
Browse files Browse the repository at this point in the history
  • Loading branch information
ekremney committed Apr 18, 2024
1 parent 430dcaf commit 753d008
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ sampleRUM.drain('cwv', (() => {
storeCWV({ name: 'LCP', value: entry.renderTime, entries: [entry] });
});

registerPerformanceObserver('navigation', (entries) => {
const entry = entries.pop();
storeCWV({ name: 'TTFB', value: entry.responseStart });
});

const cwvScript = new URL('.rum/web-vitals/dist/web-vitals.iife.js', sampleRUM.baseURL).href;
if (document.querySelector(`script[src="${cwvScript}"]`)) {
// web vitals script has been loaded already
Expand Down

0 comments on commit 753d008

Please sign in to comment.