Performance: Media formats overview
This affects page load speed and rendering performance by determining how quickly media files download and display.
<img src="photo.webp" alt="Photo">
<img src="photo.jpg" alt="Photo">
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large JPEG/PNG images | Minimal | 1 reflow per image load | High paint cost due to large decode | [X] Bad |
| WebP images | Minimal | 1 reflow per image load | Lower paint cost due to smaller size | [OK] Good |
| AVI video | Minimal | 1 reflow on video load | High paint and decode cost | [X] Bad |
| MP4 video | Minimal | 1 reflow on video load | Lower paint and decode cost | [OK] Good |
| WAV audio | Minimal | 1 reflow on audio load | High resource load cost | [X] Bad |
| OGG audio | Minimal | 1 reflow on audio load | Lower resource load cost | [OK] Good |
<audio> tag is designed to embed sound files like music or voice recordings.<img> is for images, <video> is for videos, and <sound> is not a valid HTML tag.<img> with a src attribute for the file path and an alt attribute for accessibility.<img> is self-closing and does not have a closing tag. The href attribute is incorrect for images.<video controls> <source src='movie.mp4' type='video/mp4'> <source src='movie.webm' type='video/webm'> Your browser does not support the video tag. </video>
<video> tag can have multiple <source> elements to provide different video formats for browser compatibility.controls attribute shows play/pause buttons. The fallback text appears only if the browser cannot play any source.<audio src='sound.mp3' controls> <source src='sound.ogg' type='audio/ogg'> </audio>
<source> tags inside <audio>, the src attribute on <audio> should be omitted to avoid conflicts.controls attribute is present, <source> tags do not require self-closing slash in HTML5, and type is valid.autoplay. To loop forever, use loop. To mute sound by default, use muted. Controls help user control playback.<video src='clip.mp4' autoplay loop muted controls></video> has all: autoplay, loop, muted, and controls. Others miss one or more attributes.<video src='clip.mp4' autoplay loop muted controls></video> [OK]Pass the test and this pattern moves unknown