Images are usually the heaviest part of a web page. Oversized images make pages load slowly, viewers leave, and mobile speed scores drop. The good news is that most problems can be handled with a few simple principles: choose the right format, set the right size, load images at the right time and describe images clearly.
The previous article in the speed series is INP thay FID trong Core Web Vitals. Optimizing images is one of the things that helps improve these metrics.
Choose the right format
web.dev's Images course has separate lessons on each format: GIF, PNG, JPEG, WebP and AVIF. A quick rule of thumb:
| Format | Suits | Notes |
|---|---|---|
| JPEG | Photos, many colors | Common, lossy compression |
| PNG | Images needing transparent backgrounds, graphics | Files are often large for photos |
| WebP | Most images on the web | Usually lighter than JPEG and PNG at comparable quality |
| AVIF | Images that need to be even lighter | Compresses well; check browser support and processing time |
| SVG | Logos, icons | Drawn in code, does not blur when scaled up |
With WordPress, many plugins and servers can convert images to WebP on upload. Check the result by eye, since over-compression makes images look grainy.
Set sizes to match the display frame
A common mistake is loading an original image thousands of pixels wide to display in a frame only a few hundred pixels wide. How to handle it:
- Determine the largest width at which the image is displayed on your website, then export images at that size, with a double-size version for high-resolution screens if needed.
- Use the srcset and sizes attributes so the browser picks an image of a size that suits the device. Web.dev has a separate guide on this syntax.
- Declare the image's width and height so the browser reserves space in advance, preventing content from jumping once the image loads.
Lazy load in the right places
Lazy loading means delaying image loading until the user scrolls near it. It makes the initial page lighter, but must be used correctly:
- Use it for images below the first screen, such as galleries and related posts.
- Do not use it for large images at the top of the page (hero background, a post's featured image), since that is usually the main element measured for speed. Delaying this image makes the page seem slower.
- In modern browsers, the loading attribute of the image tag already supports this without any extra library.
- Check by scrolling the page and watching whether images appear in time.
Alt text: a description for people and machines
Alt text is a short description of an image. It lets screen reader users hear the image content, shows as a replacement when the image fails to load, and helps search engines understand the image. How to write it:
- Describe it briefly and accurately, such as "a staff member checking the hosting control panel".
- Do not stuff keywords.
- Purely decorative images can have empty alt so screen readers skip them.
- If an image contains important text, repeat that text in the text around the image.
The standards for on-page information also relate to structured data: the declared description must match the visible content.
A simple process for business websites
- Prepare images at the right size before uploading; don't push originals straight from a phone or camera.
- Compress and convert to WebP or another suitable format.
- Give files clear names and write alt text.
- Turn on lazy load for images below the first screen.
- Recheck with a mobile speed testing tool and compare before and after.
Cover and illustration images for content articles should follow the same process, even when you are writing about topics such as AI Overviews. For older websites, also see Page Experience and Core Web Vitals in 2021.
Ví dụ xử lý một trang chủ nặng vì ảnh
Giả sử trang chủ có một ảnh nền lớn, sáu ảnh sản phẩm và logo các đối tác, tất cả đều là ảnh gốc xuất từ máy ảnh. Cách xử lý tuần tự: nén và đổi kích thước ảnh nền phù hợp màn hình, đặt ảnh sản phẩm về đúng khung hiển thị, đổi logo sang SVG nếu có tệp vector, và bật tải trễ cho các ảnh nằm dưới màn hình đầu. Sau mỗi bước, đo lại để biết bước nào đem lại hiệu quả nhiều nhất.
Cách kiểm tra ảnh nào đang làm nặng trang
- Mở trang bằng trình duyệt, bật công cụ dành cho nhà phát triển và vào thẻ Network.
- Lọc theo loại Img và sắp xếp theo dung lượng giảm dần.
- Ghi lại 3–5 ảnh nặng nhất, kèm kích thước hiển thị trên trang.
- So sánh kích thước tệp với kích thước hiển thị: ảnh gốc quá lớn so với khung là dấu hiệu cần xử lý trước.
Lỗi hay gặp khi tối ưu ảnh
- Nén quá tay: ảnh sản phẩm bị vỡ hạt khiến khách mất tin. Hãy xem lại ảnh ở kích thước thật.
- Đổi sang định dạng mới nhưng không có bản dự phòng: kiểm tra hỗ trợ trên các trình duyệt khách hay dùng, hoặc dùng plugin có cơ chế dự phòng.
- Lazy load cho cả ảnh đầu trang: làm phần nhìn thấy đầu tiên hiện chậm hơn.
- Quên ảnh trong CSS, slider, ảnh nền: các ảnh này không nằm trong thẻ ảnh thông thường nên dễ bị bỏ sót khi nén.
- Tên tệp vô nghĩa: đặt tên như “IMG_4821” làm mất cơ hội mô tả đúng nội dung ảnh.
Thói quen giữ ảnh nhẹ lâu dài
Đặt quy ước cho người đăng bài: chiều rộng tối đa của ảnh, định dạng ưu tiên, dung lượng mục tiêu cho từng loại ảnh. Thỉnh thoảng rà thư viện media để xoá ảnh trùng, ảnh không còn dùng. Khi thay giao diện hoặc plugin, kiểm tra lại các kích thước ảnh do giao diện tự sinh ra, vì chúng có thể thay đổi. Các khoá học của web.dev về ảnh cung cấp nền tảng cho những việc này; nguồn tra ngày 03/12/2026.
If you need help with PageSpeed optimization, you can contact HVSC's Technology team; the SEO also matter when you optimize images for search.
2026 update: Browser image format support and compression tools keep changing, so check web.dev's current documentation. For an overall check, see the 2026 SEO checklist and writing content for AI Overviews.
FAQ
Should I use WebP or AVIF?
WebP is widely supported and easy to use. AVIF can be even lighter but requires checking support and the processing pipeline. You can start with WebP.
Should I lazy load all images?
No. Large images at the top of the page should load immediately. Only lazy load images further down.
Does alt text affect SEO?
Alt text helps search engines understand images and supports accessibility. Write naturally and do not stuff keywords.
Reference sources
- web.dev, Learn Images — https://web.dev/learn/images
- Google, Introduction to structured data (reference for the principle of visible content) — https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data
Need advice on websites, software or security?
Describe the problem, and HVSC engineers will discuss the scope and options suited to your business.
FAQ
Should I use WebP or AVIF?
WebP is widely supported and easy to use. AVIF can be even lighter but requires checking support and the processing pipeline. You can start with WebP.
Should I lazy load all images?
No. Large images at the top of the page should load immediately. Only lazy load images further down.
Does alt text affect SEO?
Alt text helps search engines understand images and supports accessibility. Write naturally and do not stuff keywords.
- iPhone with full storage: back up first, then clean up, to avoid losing data
- Black Friday 2026: How to Tell Real Deals from Fake Ones Before You Buy
- Cài phần mềm trên Ubuntu: apt, snap và những lưu ý khi cập nhật













▶
▶
▶
▶
▶