Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
For modern Angular apps, start with NgOptimizedImage from @angular/common: use ngSrc, provide image dimensions, mark the page’s likely Largest Contentful Paint (LCP) image as priority, and set sizes for responsive images. A CDN loader is optional; use one when you need its image-resizing or transformation capabilities.
Enable NgOptimizedImage
Import the directive from @angular/common and add it to the component’s imports, or to the applicable NgModule imports. Change an image’s src attribute to ngSrc to activate the directive. Without a configured service loader, Angular’s generic loader uses the source URL unchanged.
import { NgOptimizedImage } from '@angular/common';
@Component({
imports: [NgOptimizedImage],
// ...
})
export class ExampleComponent {}
<img ngSrc="hero.jpg" width="1200" height="800" priority alt="Description of the image">
Use the image file’s real dimensions and concise alternative text suited to the image’s purpose. Check the Angular image optimization guide for details applicable to the Angular version in your project.
Prioritize the image most likely to be LCP
Add priority to the image likely to be the page’s LCP image. Angular documents that priority images receive high fetch priority and eager loading; when server-side rendering is used, Angular also generates a preload hint. Images without priority are lazy-loaded by default.
#1 Best Overall
The LCP image can change with viewport size and page layout. Inspect the actual page and prioritize the image that is likely to appear as LCP rather than marking every image as a priority image.
Set dimensions and responsive sizing
Set width and height so the browser can reserve image space and reduce image-related layout shifts. Keep the dimensions’ aspect ratio consistent with the source image. For responsive images, Angular’s guide recommends using the source file’s intrinsic dimensions and supplying an appropriate sizes value. For fixed-size images, use the intended rendered dimensions while preserving the source aspect ratio.
Rank #2
Use fill mode when the container determines the size
If the image size is not known in advance, Angular supports fill mode. The containing element must have position: relative, fixed, or absolute. This approach suits layouts where CSS controls the image area.
Choose how Angular builds responsive sources
Angular generates srcset based on the sizes value, using a documented default breakpoint list that projects can customize through IMAGE_CONFIG. You can instead provide ngSrcset descriptors. Angular infers the image filename from ngSrc, so descriptors do not include filenames. The guide also describes automatic insertion of sizes="auto" to improve image selection in browsers that support it.
Rank #3
After implementation, inspect the rendered layout and network requests in the target application to confirm that the browser is selecting appropriate image variants.
Choose a loader only if you need image delivery transformations
A loader is optional. The generic loader leaves the source URL unchanged. Angular documents built-in loaders for Cloudflare Image Resizing, Cloudinary, ImageKit, Imgix, and Netlify, as well as support for custom loaders for other services.
Rank #4
Choose a service based on the image host already in use, the resizing or other transformations the application needs, and the responsive variants the service can deliver. Angular’s documentation does not establish that a provider is free or suitable for every workload; check the provider’s current terms and operational constraints separately.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →The built-in Cloudinary, Cloudflare, ImageKit, and Imgix loaders support the special transform property. Netlify’s loader does not. See Angular’s loader documentation for configuration details.
Understand placeholders and CSS background images
Automatic blurred placeholders need a suitable loader
Angular can request a smaller image to create an automatic blurred placeholder when a configured loader can provide that smaller image. Without a loader capable of requesting it, Angular cannot generate the placeholder.
Move an important CSS background image into an img element
For a CSS background image that should use Angular’s image-loading features, the guide describes placing the image in a child <img> with ngSrc and fill. Position the containing element, then add priority if that image is likely to be the page’s LCP image.
Check the result in your application
- Confirm that each optimized image uses
ngSrcand has suitable dimensions or a correctly configuredfillcontainer. - Check that the likely LCP image is prioritized and that other images retain the intended lazy-loading behavior.
- For responsive images, verify that
sizesmatches the rendered layout and that requested variants are appropriate. - If using a CDN loader, confirm the generated URLs and transformations against the service’s current capabilities.
Angular’s documentation describes implementation practices, not a guaranteed performance percentage or measured Core Web Vitals improvement. Actual results depend on the page, images, delivery setup, and browser behavior.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

