forked from debinzhang/debinzhang.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload1.html
32 lines (28 loc) · 919 Bytes
/
preload1.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Responsive preload example</title>
<link rel="preload" href="bg-image-narrow.png" as="image" media="(max-width: 600px)" >
<link rel="preload" href="bg-image-wide.png" as="image" media="(min-width: 601px)" >
<link rel="preload" href="mint1.jpg" as="fetch" >
<link rel="stylesheet" href="main.css">
</head>
<body>
<header>
<h1>My site 9</h1>
</header>
<script>
var mediaQueryList = window.matchMedia("(max-width: 600px)");
var header = document.querySelector('header');
if(mediaQueryList.matches) {
header.style.backgroundImage = 'url(bg-image-narrow.png)';
} else {
header.style.backgroundImage = 'url(bg-image-wide.png)';
}
</script>
<img src="mount.jpeg" >
<img src="s_man.gif" style="display: none;" />
<img src="mint1.jpg">
</body>
</html>