66 * found in the LICENSE file at https://angular.dev/license
77 */
88
9- import { IMAGE_CONFIG , ImageConfig , PLATFORM_ID } from './application/application_tokens' ;
9+ import { IMAGE_CONFIG , ImageConfig } from './application/application_tokens' ;
1010import { Injectable } from './di' ;
1111import { inject } from './di/injector_compatibility' ;
1212import { formatRuntimeError , RuntimeErrorCode } from './errors' ;
@@ -27,12 +27,11 @@ export class ImagePerformanceWarning implements OnDestroy {
2727 private window : Window | null = null ;
2828 private observer : PerformanceObserver | null = null ;
2929 private options : ImageConfig = inject ( IMAGE_CONFIG ) ;
30- private readonly isBrowser = inject ( PLATFORM_ID ) === 'browser' ;
3130 private lcpImageUrl ?: string ;
3231
3332 public start ( ) {
3433 if (
35- ! this . isBrowser ||
34+ ( typeof ngServerMode !== 'undefined' && ngServerMode ) ||
3635 typeof PerformanceObserver === 'undefined' ||
3736 ( this . options ?. disableImageSizeWarning && this . options ?. disableImageLazyLoadWarning )
3837 ) {
@@ -41,7 +40,7 @@ export class ImagePerformanceWarning implements OnDestroy {
4140 this . observer = this . initPerformanceObserver ( ) ;
4241 const doc = getDocument ( ) ;
4342 const win = doc . defaultView ;
44- if ( typeof win !== 'undefined' ) {
43+ if ( win ) {
4544 this . window = win ;
4645 // Wait to avoid race conditions where LCP image triggers
4746 // load event before it's recorded by the performance observer
0 commit comments