Using browser settings for performance
- 3. MOBILE
<video autoplay loop muted playsinline controls>
<source src="vid.mp4" media="(min-width: 1280px)" type="video/mp4">
<img src="screenshot.jpg" alt="Video screenshot">
</video>
- 4. MOBILE
Problem: Video media query support has been
removed from Google Chrome 34+
<video autoplay loop muted playsinline controls>
<source src="vid.mp4" media="(min-width: 1280px)" type="video/mp4">
<img src="screenshot.jpg" alt="Video screenshot">
</video>
- 5. LOADWITHJAVASCRIPT
<video id="video" preload="none" loop muted playsinline controls
poster="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.o
src="small.mp4"
</video>
<script>
var video = document.getElementById('video')
if (is_mobile()) {
video.setAttribute('poster', 'screenshot.jpg')
} else {
video.setAttribute('src', 'large.mp4')
video.play()
}
</script>
- 6. ISMOBILE?
<script>
function is_mobile() {
var mobile = true
if (
!navigator.userAgent.match(/Mobi/) ||
window.screen.width > 1599 ||
window.matchMedia('(min-width: 1280px)').matches
) {
mobile = false
}
return mobile
}
</script>
- 9. DONOTTRACK
Ignoring DNT is a (potential) GDPR violation
HTTP Request Header
DNT: 1
<?php
if (empty($_SERVER['HTTP_DNT'])) {
echo '<script src="trackme.js" async></script>';
}
- 10. HIGHCONTRASTMODE(EDGE)
<style>
@media screen and (-ms-high-contrast: active) {
/* All high contrast styling rules */
}
</style>
<script>
if (window.matchMedia('(-ms-high-contrast: active)').matches) {
// High contrast code
}
</script>
https://msdn.microsoft.com/library/Hh771830
- 14. NETWORKINFORMATIONAPI
<script>
var connection = navigator.connection || navigator.mozConnection || n
if (
connection &&
(
connection.type === 'ethernet' ||
connection.type === 'wifi' ||
connection.type === '4g'
)
) {
// Do something
}
</script>
- 16. CLIENTHINTS
HTTP Request Headers
Accept: image/webp,image/*,*/*;q=0.8
Accept-CH: DPR, Width
Accept-CH: Viewport-Width
https://httpwg.org/http-extensions/client-hints.html
https://www.smashingmagazine.com/2016/01/leaner-responsive-images-client-hints/