-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
40 lines (36 loc) · 947 Bytes
/
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title></title>
<script type="text/javascript" src="require_script.js"></script>
</head>
<body>
<h1>Require with timeout</h1>
<button id="go">Require script</button>
<button id="goWorker">Require script in worker</button>
</body>
<script>
document.querySelector('#go').addEventListener('click', function() {
requireScript('example.js', function() {
example();
});
});
document.querySelector('#goWorker').addEventListener('click', function() {
var worker = new Worker('worker.js');
worker.onmessage = function(e) {
switch (e.data.action) {
case 'end':
worker.terminate();
break;
}
};
var message = {
action: 'start'
};
worker.postMessage(message);
});
</script>
</html>