CKTIS / JavaScript
Progressive enhancement
Progressive enhancement means building working baseline functionality before adding optional JavaScript improvements. The user's main task should remain available when a script does not download, does not run, or lacks a required environment capability.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
Baseline functionality → capability detection → optional JavaScript enhancementProgressive enhancement is a design strategy, not an ECMAScript syntax construct. First provide baseline functionality using HTML and, where needed, server-side handling. JavaScript adds convenience but should not be the only route to completing the main task. For example, an ordinary link can work without a script, while a script additionally updates a message.
Detect the specific capability you need instead of identifying the browser by name. In the example, typeof link.addEventListener === "function" checks that the method is available before calling it. This test does not prove that later operations will always succeed. It also cannot protect against a parsing error from syntax the engine does not understand: capability-detection code must itself be understandable to the target environment.
The example preserves href="#answer" and does not call preventDefault(), so baseline navigation does not depend on the event handler. After the link is activated, JavaScript adds the text Ready.. Test both the enhanced version and the version without JavaScript. Unlike graceful degradation, which starts with a richer version and provides fallback behavior, this strategy starts with a working baseline.
The ECMAScript specification describes the language mechanisms used here, including typeof, but does not define this strategy or browser DOM APIs. The example requires a browser; having Node 24 in a repository does not establish browser API support or compatibility with target browsers.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Progressive enhancement</title>
<a id="jump" href="#answer">Read the answer</a>
<p id="status" role="status"></p>
<h2 id="answer">Answer</h2>
<p>The link works without JavaScript.</p>
<script>
(function () {
var link = document.getElementById("jump");
var status = document.getElementById("status");
if (link && status && typeof link.addEventListener === "function") {
link.addEventListener("click", function () {
status.textContent = "Ready.";
});
}
}());
</script>
</html>Result
Ready.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.