diff --git a/packages/common/src/directives/ng_optimized_image/tokens.ts b/packages/common/src/directives/ng_optimized_image/tokens.ts index 32348cc8ac1..1ccc422708a 100644 --- a/packages/common/src/directives/ng_optimized_image/tokens.ts +++ b/packages/common/src/directives/ng_optimized_image/tokens.ts @@ -23,7 +23,10 @@ export const DEFAULT_PRELOADED_IMAGES_LIMIT = 5; * This Set tracks the original src passed into the `ngSrc` input not the src after it has been * run through the specified `IMAGE_LOADER`. */ -export const PRELOADED_IMAGES = new InjectionToken>('NG_OPTIMIZED_PRELOADED_IMAGES', { - providedIn: 'root', - factory: () => new Set(), -}); +export const PRELOADED_IMAGES = new InjectionToken>( + typeof ngDevMode === 'undefined' || ngDevMode ? 'NG_OPTIMIZED_PRELOADED_IMAGES' : '', + { + providedIn: 'root', + factory: () => new Set(), + }, +);