forked from chase-moskal/webp-hero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esm.html
35 lines (29 loc) · 929 Bytes
/
esm.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
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>webp-hero</title>
</head>
<body>
<h1>webp-hero</h1>
<p>view source on <a href="https://github.com/chase-moskal/webp-hero">github</a></p>
<img alt="" src="images/dice.webp"/>
<img alt="" src="images/landscape.webp"/>
<img alt="" src="images/firebreather.webp"/>
<script type="module">
import {WebpMachine} from "./dist/webp-machine.js"
async function main() {
// for this demo, you can add "?force" to the url to force webp conversion
const webpSupport = location.search.indexOf("force") !== -1
? Promise.resolve(false)
: undefined
// instance the webp machine
const webpMachine = new WebpMachine({webpSupport})
// polyfill this entire document's webp images
await webpMachine.polyfillDocument()
}
main()
.catch(error => console.error("top level error:", error))
</script>
</body>
</html>