Last updated: August 27, 2026.
Load JavaScript as a module and update the DOM with textContent.
HTML
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>First JavaScript program</title>
<h1 id="greeting">Loading…</h1>
<script type="module" src="app.js"></script>
</html>JavaScript
const heading = document.querySelector("#greeting");
const formatter = new Intl.DateTimeFormat(undefined, { dateStyle: "full" });
heading.textContent = `Hello! Today is ${formatter.format(new Date())}.`;Module scripts are deferred automatically. Use the developer console to inspect errors and continue with the MDN JavaScript Guide.