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/changing-src.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Changing the src of a script element should re-load it</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
async_test(t => {
const script = document.createElement("script");
document.body.appendChild(script);
script.onload = () => {
assert_equals(window.scriptExecuted, true);
t.done();
};
script.src = "changing-src.js";
}, "adding a src attribute after inserting the script into the document causes the script to load and execute");
</script>
</body>