Skip to content

Commit 20cfb44

Browse files
committed
save a couple of bytes
1 parent a8d733f commit 20cfb44

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

packages/browser-utils/src/metrics/browserMetrics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function startTrackingWebVitals({ recordClsStandaloneSpans }: StartTracki
9292
fidCleanupCallback();
9393
lcpCleanupCallback();
9494
ttfbCleanupCallback();
95-
clsCleanupCallback();
95+
clsCleanupCallback && clsCleanupCallback();
9696
};
9797
}
9898

packages/browser-utils/src/metrics/cls.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ import { onHidden } from './web-vitals/lib/onHidden';
2323
* Once either of these events triggers, the CLS value is sent as a standalone span and we stop
2424
* measuring CLS.
2525
*/
26-
export function trackClsAsStandaloneSpan(): () => void {
26+
export function trackClsAsStandaloneSpan(): void {
2727
let standaloneCLsValue = 0;
2828
let standaloneClsEntry: LayoutShift | undefined;
2929

30-
// Cleanup for standalone span mode is handled in this function.
31-
// Returning a no-op for API compatibility with `_trackCLS` measurement mode (saves some bytes)
32-
const cleanupNoop = () => undefined;
33-
3430
if (!supportsLayoutShift()) {
35-
return cleanupNoop;
31+
return;
3632
}
3733

3834
let sentSpan = false;
@@ -68,8 +64,6 @@ export function trackClsAsStandaloneSpan(): () => void {
6864
typeof unsubscribe === 'function' && unsubscribe();
6965
});
7066
}, 0);
71-
72-
return cleanupNoop;
7367
}
7468

7569
function sendStandaloneClsSpan(clsValue: number, entry: LayoutShift | undefined) {

0 commit comments

Comments
 (0)