Skip to content

Commit

Permalink
fix(core): Do not run image performance warning checks on server
Browse files Browse the repository at this point in the history
These checks require document so they should not be run on the server.
  • Loading branch information
atscott committed Aug 1, 2024
1 parent 147eee4 commit 8e0925b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/image_performance_warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {IMAGE_CONFIG, ImageConfig} from './application/application_tokens';
import {IMAGE_CONFIG, ImageConfig, PLATFORM_ID} from './application/application_tokens';
import {Injectable} from './di';
import {inject} from './di/injector_compatibility';
import {formatRuntimeError, RuntimeErrorCode} from './errors';
Expand All @@ -27,10 +27,12 @@ export class ImagePerformanceWarning implements OnDestroy {
private window: Window | null = null;
private observer: PerformanceObserver | null = null;
private options: ImageConfig = inject(IMAGE_CONFIG);
private readonly isBrowser = inject(PLATFORM_ID) === 'browser';
private lcpImageUrl?: string;

public start() {
if (
!this.isBrowser ||
typeof PerformanceObserver === 'undefined' ||
(this.options?.disableImageSizeWarning && this.options?.disableImageLazyLoadWarning)
) {
Expand Down

0 comments on commit 8e0925b

Please sign in to comment.