|
| 1 | +:!sectids: |
| 2 | + |
| 3 | +== Why is this an issue? |
| 4 | + |
| 5 | +Autoplaying media consumes unnecessary energy, especially when users might not be actively engaging with the content. |
| 6 | +This can drain battery life on devices, particularly on mobile devices, leading to increased energy consumption and potentially contributing to environmental impact. |
| 7 | +It can also consume data, particularly for users on limited data plans or in areas with poor internet connectivity. |
| 8 | +This can lead to unnecessary data usage and potentially increased costs for users. |
| 9 | + |
| 10 | +However, even without autoplay, segments of video or audio files might still download. |
| 11 | +This leads to unnecessary data usage, especially if users don't commence playback. |
| 12 | +To mitigate this, it's crucial to prevent browsers from preloading any content by configuring the appropriate settings. |
| 13 | + |
| 14 | +Video: |
| 15 | + |
| 16 | +[source,typescriptjsx,data-diff-id="3",data-diff-type="noncompliant"] |
| 17 | +---- |
| 18 | +return ( |
| 19 | + <> |
| 20 | + <video src="video.mp4" autoplay/> // Non-compliant |
| 21 | + <video src="video.mp4" preload="auto"/> // Non-compliant |
| 22 | + <video src="video.mp4" autoplay preload="auto"/> // Non-compliant |
| 23 | + </> |
| 24 | +) |
| 25 | +---- |
| 26 | + |
| 27 | +[source,typescriptjsx,data-diff-id="2",data-diff-type="compliant"] |
| 28 | +---- |
| 29 | +return ( |
| 30 | + <video src="video.mp4" preload="none"/> // Compliant |
| 31 | +) |
| 32 | +---- |
| 33 | + |
| 34 | +Audio: |
| 35 | + |
| 36 | +[source,typescriptjsx,data-diff-id="2",data-diff-type="noncompliant"] |
| 37 | +---- |
| 38 | +return ( |
| 39 | + <audio controls src="audiofile.mp3" autoplay></audio> // Non-compliant |
| 40 | +) |
| 41 | +---- |
| 42 | + |
| 43 | +[source,typescriptjsx,data-diff-id="2",data-diff-type="compliant"] |
| 44 | +---- |
| 45 | +return ( |
| 46 | + <audio controls src="audiofile.mp3" preload="none"></audio> // Compliant |
| 47 | +) |
| 48 | +---- |
| 49 | + |
| 50 | +== Resources |
| 51 | + |
| 52 | +=== Documentation |
| 53 | + |
| 54 | +- https://github.com/cnumr/best-practices/blob/main/chapters/BP_4003_en.md[CNUMR best practices] - Avoid autoplay for videos and audio content |
| 55 | + |
| 56 | +=== Articles & blog posts |
| 57 | + |
| 58 | +- https://eco-conception.designersethiques.org/guide/en/content/5-2-video.html[eco-conception.designersethiques.org - 5.2. Video and sound] |
| 59 | +- https://www.ecoindex.fr/en/ecodesign/[www.ecoindex.fr - Some good practices] |
0 commit comments