Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/scripting-1/the-script-element/dynamically-created-defer-script.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Dynamically created defer scripts inserted after DOMContentLoaded</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
window.scriptRan = false;
async_test(t => {
window.addEventListener("DOMContentLoaded", t.step_func(() => {
const s = document.createElement("script");
s.defer = true;
s.src = "resources/dynamically-created-defer-script.js";
document.head.append(s);
s.onload = t.step_func_done(() => {
assert_true(window.scriptRan);
});
}));
});
</script>