-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (74 loc) · 2.43 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test app</title>
<!-- Building blocks -->
<link rel="stylesheet" href="style/headers.css">
<link rel="stylesheet" href="style/lists.css">
<link rel="stylesheet" href="style/responsive.css">
<link rel="stylesheet" href="style/app.css">
</head>
<body>
<section id="index">
<section role="region" class="skin-organic">
<header>
<h1>Gradient performance</h1>
</header>
</section>
<section data-type="list" id="list">
<ul>
<h2>Click on the list to create 1000 headers</h2>
<h3>Colors are slightly different to see they change</h3>
<li>
<a id="btn-action-1" href="#">
<p>PNG image</p>
<p class="time"></p>
</a>
</li>
<li>
<a id="btn-action-2" href="#">
<p>SVG image</p>
<p class="time"></p>
</a>
</li>
<li>
<a id="btn-action-3" href="#">
<p>CSS gradient</p>
<p class="time"></p>
</a>
</li>
</ul>
</section>
<section id="container"></section>
</section> <!-- end index -->
<script>
function addElements(element,cls,item) {
document.querySelector('#btn-action-1').className = '';
document.querySelector('#btn-action-2').className = '';
document.querySelector('#btn-action-3').className = '';
item.className = 'current';
container = document.querySelector('#container');
container.innerHTML = "";
var t0 = window.performance.now();
for (var i = 0; i < 1000; i ++) {
var header = document.createElement('div');
header.innerHTML = '<header class="'+cls+'"><h1>Header '+ (i+1) +'</h1></header>';
container.appendChild(header);
}
var t1 = window.performance.now();
item.querySelector('.time').innerHTML = "time: " + Math.round((t1 - t0) * 100) / 100
+ " msec";
}
document.querySelector('#btn-action-1').addEventListener ('click', function () {
addElements(document.querySelector('#index'),'image',this);
});
document.querySelector('#btn-action-2').addEventListener ('click', function () {
addElements(document.querySelector('#index'),'svg',this);
});
document.querySelector('#btn-action-3').addEventListener ('click', function () {
addElements(document.querySelector('#index'),'css',this);
});
</script>
</body>
</html>