recommended
config.
Automatic videos and audio files activation (autoplay) during web pages loading uses resources on each tier (device,
network, data center). In many cases, automatic playback is not necessary. Moreover, it can draw users' attention and
distract them from the initially requested service. Therefore, whenever possible, these playbacks should be initiated by
the users and by not using the autoplay attributes in the <audio>
and <video>
elements.
Nevertheless, some parts of the video or audio files may be downloaded even if autoplay is not activated. Moreover, data
will be unnecessarily downloaded even if users do not start the video playback. It is therefore necessary to force
browsers not to preload anything by setting the preload
attribute to none
.
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
<video src="video.mp4" preload="none"/> // Compliant
</>
)
This rule is build for React and JSX.
- Mozilla Web Technology for Developers - Autoplay in HTML
- Mozilla Web Technology for Developers - Video and audio content
- Mozilla Web Technology for Developers - Preload in HTML
- W3C - Autoplay attribute
- RGESN - Reference Rule 4.1