blob: b1c381aaa553355ee7afb3b2dd27165d20123051 (
plain)
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
|
<html>
<head>
<title>Inserted script test</title>
<script>
/* After one second, insert an inline script element */
setTimeout(function() {
var div = document.createElement("DIV");
var script = document.createElement("SCRIPT");
var textnode = document.createTextNode("console.log(\"Dynamism\");");
script.appendChild(textnode);
div.appendChild(script);
document.body.appendChild(div);
}, 1000);
/* After two seconds, insert a script element for immediate fetch */
setTimeout(function() {
var script = document.createElement("SCRIPT");
script.setAttribute("src", "inserted-script.js");
document.body.appendChild(script);
}, 2000);
/* After three seconds, insert a script element for async fetch */
setTimeout(function() {
var script = document.createElement("SCRIPT");
script.setAttribute("src", "inserted-script-async.js");
script.setAttribute("async", "");
document.body.appendChild(script);
}, 3000);
/* After four seconds, insert a script element for deferred fetch */
setTimeout(function() {
var script = document.createElement("SCRIPT");
script.setAttribute("src", "inserted-script-defer.js");
script.setAttribute("defer", "");
document.body.appendChild(script);
}, 4000);
</script>
</head>
<body>
Check the log
</body>
</html>
|