Skip to content

Commit 9cdb602

Browse files
committed
add preload.html
1 parent 2fe6715 commit 9cdb602

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

preload.html

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
<head>
22
<meta charset="utf-8">
3-
<title>Image preload example</title>
3+
<title>Responsive preload example</title>
44

55
<link rel="preload" href="mint1.jpg" as="image" media="(max-width: 600px)">
6+
<link rel="preload" href="mint3.jpg" as="image" media="(min-width: 601px)">
67

8+
<link rel="stylesheet" href="main.css">
79
</head>
8-
910
<body>
10-
<h1>proload test 1</h1>
11-
<canvas></canvas>
11+
<header>
12+
<h1>My site</h1>
13+
</header>
1214

13-
<p>
14-
<img src=mint3.jpg>
15-
</p>
15+
<script>
16+
var mediaQueryList = window.matchMedia("(max-width: 600px)");
17+
var header = document.querySelector('header');
1618

19+
if(mediaQueryList.matches) {
20+
header.style.backgroundImage = 'url(mint1.jpg)';
21+
} else {
22+
header.style.backgroundImage = 'url(mint3.jpg)';
23+
}
24+
</script>
1725
</body>

0 commit comments

Comments
 (0)