-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Porting GCI36 rule to JavaScript (#370)
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
:!sectids: | ||
|
||
== Why is this an issue? | ||
|
||
Autoplaying media consumes unnecessary energy, especially when users might not be actively engaging with the content. | ||
This can drain battery life on devices, particularly on mobile devices, leading to increased energy consumption and potentially contributing to environmental impact. | ||
It can also consume data, particularly for users on limited data plans or in areas with poor internet connectivity. | ||
This can lead to unnecessary data usage and potentially increased costs for users. | ||
|
||
However, even without autoplay, segments of video or audio files might still download. | ||
This leads to unnecessary data usage, especially if users don't commence playback. | ||
To mitigate this, it's crucial to prevent browsers from preloading any content by configuring the appropriate settings. | ||
|
||
Video: | ||
|
||
[source,typescriptjsx,data-diff-id="3",data-diff-type="noncompliant"] | ||
---- | ||
return ( | ||
<> | ||
<video src="video.mp4" autoplay/> // Non-compliant | ||
<video src="video.mp4" preload="auto"/> // Non-compliant | ||
<video src="video.mp4" autoplay preload="auto"/> // Non-compliant | ||
</> | ||
) | ||
---- | ||
|
||
[source,typescriptjsx,data-diff-id="2",data-diff-type="compliant"] | ||
---- | ||
return ( | ||
<video src="video.mp4" preload="none"/> // Compliant | ||
) | ||
---- | ||
|
||
Audio: | ||
|
||
[source,typescriptjsx,data-diff-id="2",data-diff-type="noncompliant"] | ||
---- | ||
return ( | ||
<audio controls src="audiofile.mp3" autoplay></audio> // Non-compliant | ||
) | ||
---- | ||
|
||
[source,typescriptjsx,data-diff-id="2",data-diff-type="compliant"] | ||
---- | ||
return ( | ||
<audio controls src="audiofile.mp3" preload="none"></audio> // Compliant | ||
) | ||
---- | ||
|
||
== Resources | ||
|
||
=== Documentation | ||
|
||
- https://github.com/cnumr/best-practices/blob/main/chapters/BP_4003_en.md[CNUMR best practices] - Avoid autoplay for videos and audio content | ||
|
||
=== Articles & blog posts | ||
|
||
- https://eco-conception.designersethiques.org/guide/en/content/5-2-video.html[eco-conception.designersethiques.org - 5.2. Video and sound] | ||
- https://www.ecoindex.fr/en/ecodesign/[www.ecoindex.fr - Some good practices] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"tags": ["creedengo", "eco-design", "react-native", "video", "audio"], | ||
"compatibleLanguages": ["JAVASCRIPT", "TYPESCRIPT"] | ||
} |