-
Notifications
You must be signed in to change notification settings - Fork 46
/
index.html
59 lines (53 loc) · 1.33 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WebP image replacement with htaccess</title>
<style>
* {
margin: 0
}
body {
padding: 20px;
}
div {
display: inline-block;
max-width: 350px;
margin: 20px 20px 0 0;
}
img {
width: 100%;
}
span {
display: block;
width: 100%;
height: 50vh;
background: 0 100% / cover transparent no-repeat url('/images/image1.jpg');
}
</style>
</head>
<body>
<h1>WebP image replacement with htaccess</h1>
<p>Browser support WebP: <strong class="js-test">loading...</strong></p>
<main>
<div>
<p>1. This image is available as both webp and jpg.</p>
<img src="images/image1.jpg" />
</div>
<div>
<p>2. This image is only available as a jpg.</p>
<img src="images/image2.jpg" />
</div>
<div>
<p>3. This div has an image background set with a jpg image. It should serve a webp image if supported.</p>
<span class="background-div"></span>
</div>
</main>
<script src="modernizr-webp.js"></script>
<script>
Modernizr.on('webp', function (result) {
document.querySelector('.js-test').textContent = result
})
</script>
</body>
</html>