-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest-sw.html
37 lines (31 loc) · 1.26 KB
/
test-sw.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BPG2JPG transparent service worker polyfill demo</title>
<style>
</style>
<script>
navigator.serviceWorker.register('./sw.js', {}).then(function(reg) {
console.log('service worker on-line!');
}, function(err) {
console.log('oops, service worker install kicked the bucket :(', err);
throw err;
});</script>
<script>
</script>
</head>
<body>
<h1>BPG2JPG transparent service worker polyfill demo</h1>
<p>
Once the service worker attached to the page is loaded and installed, reload the page to have all BPG images automatically transcoded into JPEG (and cached) in the background by the service worker:
</p>
<img src="test.bpg" alt="Test BPG image file" />
<p>
Note that on first reload it might take up to a second for the above image to appear (especially on slower systems & mobile). This is because the service worker has to fetch the image from the network, and convert it into JPG format.
</p>
<p>
On subsequent reloads you will notice that the image is loaded almost instantly - since the service worker will serve the already-cashed JPG file for the request.
</p>
</body>
</html>