HEROVIDEOPERFORMANCE
WalterEbert
walterebert.com
https://yoast.com/video-backgrounds-suck/
https://yoast.com/video-backgrounds-suck/
AUTOPLAYINGVIDEOS
<video autoplay loop muted playsinline>
<source src="video.mp4" type="video/mp4">
</video>
AUTOPLAYINGVIDEOS
muted: Chrome, iOS, Android
playsinline: iOS
<video autoplay loop muted playsinline>
<source src="video.mp4" type="video/mp4">
</video>
REMOVEAUDIOTRACK
ffmpeg -i input.mp4 -an -c:v copy output.mp4
REMOVEAUDIOTRACK
Also possible with
ffmpeg -i input.mp4 -an -c:v copy output.mp4
HandBrake
MOOV-ATOM(MP4)
ffmpeg -i input.mp4 -an -c:v copy -movflags +faststart output.mp4
https://www.adobe.com/devnet/video/articles/mp4_movie_atom.html
https://www.adobe.com/devnet/video/articles/mp4_movie_atom.html
ALLTHECODECS!
<video autoplay loop muted playsinline>
<source src="av1.webm" type='video/webm;codecs="av01.0.05M.08"'>
<source src="av1.mp4" type='video/mp4;codecs="av01.0.05M.08"'>
<source src="h265.mp4" type='video/mp4;codecs="hvc1.1.L0.0"'>
<source src="vp9.webm" type='video/webm;codecs="vp9"'>
<source src="h264.mp4" type='video/mp4'>
</video>
REASONSNOTTO
LOADVIDEO
MOBILE(INTHEORY)
<video autoplay loop muted playsinline>
<source src="vid.mp4" media="(min-width: 1366px)" type="video/mp4">
<img src="screenshot.jpg" alt="Video screenshot">
</video>
MOBILE
Problem: Video Media Query support was
removed from Chrome + Firefox
<video autoplay loop muted playsinline>
<source src="vid.mp4" media="(min-width: 1366px)" type="video/mp4">
<img src="screenshot.jpg" alt="Video screenshot">
</video>
SVGPLACEHOLDER
<style>
#hero svg, #hero video, #hero img {
height: auto; width: 100%;
}
</style>
<div id="hero">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="9"/>
</div>
SVGPLACEHOLDER
<script>
var hero = document.getElementById('hero')
if (window.screen.width > 1365) {
var video = document.createElement('video')
video.src = 'video.mp4'
video.setAttribute('muted', 'muted')
video.setAttribute('loop', 'loop')
hero.innerHTML = ''
hero.appendChild(video)
video.play()
} else {
hero.innerHTML = '<img src="screenshot.jpg" alt="screenshot">'
}
SVGASPOSTERIMAGE
<video id="hero" preload="none" loop muted playsinline
poster="data:image/svg+xml,%3Csvg%20xmlns%3D%22...">
</video>
<script>
var video = document.getElementById('hero')
if (window.screen.width > 1365) {
video.setAttribute('src', 'large.mp4')
video.play()
} else {
video.setAttribute('poster', 'screenshot.jpg')
video.setAttribute('controls', 'controls')
video.setAttribute('src', 'small.mp4')
}
ISMOBILE?
<script>
...
navigator.userAgent.match(/Mobi/)
window.screen.width > 1599
window.matchMedia('(min-width: 1366px)').matches
...
</script>
ISVISIBLE?
<video id="hero" preload="none" loop muted playsinline src="v.mp4"/>
<script>
if ("hidden" in document) {
var hero = document.getElementById('hero')
if (!document.hidden) hero.play()
document.addEventListener('visibilitychange', function () {
if (document.hidden) hero.pause()
else hero.play()
}, false)
}
</script>
REDUCEDMOTION
<script>
var autoplay = true
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
autoplay = false
}
</script>
https://caniuse.com/prefers-reduced-motion
https://caniuse.com/prefers-reduced-motion
CHROMEDATASAVER
<script>
var autoplay = true
if ("connection" in navigator && navigator.connection.saveData) {
autoplay = false
}
</script>
<?php
if (empty($_SERVER['HTTP_SAVE_DATA'])) {
// Load video
}
https://developer.chrome.com/multidevice/data-compression
https://developer.chrome.com/multidevice/data-compression
DONOTTRACK
Relevant for GDPR
<script>
var autoplay = true
if ("doNotTrack" in navigator && navigator.doNotTrack === "1") {
autoplay = false
}
</script>
<?php
if (empty($_SERVER['HTTP_DNT']) ||
$_SERVER['HTTP_DNT'] === 'unspecified') {
// Video von Drittanbieter (YouTube, Vimeo, ...)
}
https://www.praetor.im/notizen/please-do-not-track/
https://www.praetor.im/notizen/please-do-not-track/
MODERNJAVASCRIPT
<script type="module">
let autoplay = true
</script>
<script nomodule>
var autoplay = false
</script>
NETWORKINFORMATIONAPI
<script>
var autoplay = false
if (
"connection" in navigator &&
(
navigator.connection.type === 'ethernet' ||
navigator.connection.type === 'wifi' ||
navigator.connection.type === '4g'
)
) {
autoplay = true
}
</script>
https://caniuse.com/netinfo
https://caniuse.com/netinfo
AUTOPLAYACTIVE?
<script>
window.setTimeout(function () {
var hero = document.getElementById('hero')
if (hero.paused) {
hero.setAttribute('controls', 'controls')
hero.setAttribute('poster', 'screenshot.jpg')
}
}, 2000)
</script>
https://www.w3.org/2010/05/video/mediaevents.html
https://www.w3.org/2010/05/video/mediaevents.html
VIDEOASANIMAGE
<picture>
<source srcset="video.mp4" type="video/mp4">
<source srcset="video.webp" type="image/webp">
<img src="video.gif" alt="Video">
</picture>
https://calendar.perfplanet.com/2017/animated-gif-without-the-gif/
https://calendar.perfplanet.com/2017/animated-gif-without-the-gif/
QUESTIONS?
social.walterebert.com/@walterebert
walterebert.com

More Related Content

PDF
FrOSCon 2023: WordPress als ActivityPub-Instanz
PDF
Sicherheit für WordPress
PDF
WordPress aufräumen - WordCamp Stuttgart
PDF
WordPress aufräumen
PDF
Hero Video Performance
PDF
WordPress-Webseiten umziehen / online stellen
PDF
Using browser settings for performance
PDF
Das richtige WordPress-Theme finden
FrOSCon 2023: WordPress als ActivityPub-Instanz
Sicherheit für WordPress
WordPress aufräumen - WordCamp Stuttgart
WordPress aufräumen
Hero Video Performance
WordPress-Webseiten umziehen / online stellen
Using browser settings for performance
Das richtige WordPress-Theme finden

More from Walter Ebert (20)

PDF
WordPress Health Check - WordCamp Würzburg
PDF
WordPress Health Check
PDF
Making WordPress fast(er)
PDF
Testumgebungen für WordPress
PDF
Modernism in Web Design
PDF
WordPress Multisite
PDF
Weniger aus Bilder holen
PDF
WordPress mit Composer und Git verwalten
PDF
High Performance Images
PDF
HTTPS + Let's Encrypt
PDF
WordPress-Templates mit Twig erstellen - PHPUGFFM
PDF
Bilder usw...
PDF
WordPress-Themes mit Twig entwickeln
PDF
Bilder einbinden ist kein Thema, oder?
PDF
Mehr Performance für WordPress - WordCamp Köln
PDF
Mehr Performance für WordPress - WPFra
PDF
Sinn und Unsinn von SSL
PDF
Above the fold content
PDF
Responsive Videos, mehr oder weniger
PDF
Die .htaccess richtig nutzen
WordPress Health Check - WordCamp Würzburg
WordPress Health Check
Making WordPress fast(er)
Testumgebungen für WordPress
Modernism in Web Design
WordPress Multisite
Weniger aus Bilder holen
WordPress mit Composer und Git verwalten
High Performance Images
HTTPS + Let's Encrypt
WordPress-Templates mit Twig erstellen - PHPUGFFM
Bilder usw...
WordPress-Themes mit Twig entwickeln
Bilder einbinden ist kein Thema, oder?
Mehr Performance für WordPress - WordCamp Köln
Mehr Performance für WordPress - WPFra
Sinn und Unsinn von SSL
Above the fold content
Responsive Videos, mehr oder weniger
Die .htaccess richtig nutzen
Ad

Recently uploaded (20)

PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
Microsoft User Copilot Training Slide Deck
PPTX
Training Program for knowledge in solar cell and solar industry
PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PDF
Auditboard EB SOX Playbook 2023 edition.
PDF
SaaS reusability assessment using machine learning techniques
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
Statistics on Ai - sourced from AIPRM.pdf
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
sbt 2.0: go big (Scala Days 2025 edition)
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Improvisation in detection of pomegranate leaf disease using transfer learni...
Convolutional neural network based encoder-decoder for efficient real-time ob...
Microsoft User Copilot Training Slide Deck
Training Program for knowledge in solar cell and solar industry
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
4 layer Arch & Reference Arch of IoT.pdf
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
Auditboard EB SOX Playbook 2023 edition.
SaaS reusability assessment using machine learning techniques
Enhancing plagiarism detection using data pre-processing and machine learning...
NewMind AI Weekly Chronicles – August ’25 Week IV
Statistics on Ai - sourced from AIPRM.pdf
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Ad

Hero Video Performance - DrupalCamp Ruhr