From a9916053d9bbad77143d34dd7fdd5ed8b2394413 Mon Sep 17 00:00:00 2001 From: Mathias Picker <48158184+MathiasWP@users.noreply.github.com> Date: Thu, 28 May 2026 21:08:42 +0200 Subject: [PATCH] perf: use createElement instead of createElementNS for HTML elements (#18262) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary The current wrapper always calls `document.createElementNS(namespace ?? NAMESPACE_HTML, tag, options)` — even for HTML elements (the >99% case), and even when `options` would be `undefined`. Two effects compound: 1. **Route HTML elements through `createElement`** — Blink has a fast path that skips the namespace lookup `createElementNS` always performs. 2. **Omit the trailing `undefined` argument** — V8/Blink take a slower path for `createElementNS(ns, tag, undefined)` (and `createElement(tag, undefined)`) than for the bare 2-arg form. This applies symmetrically to the SVG/MathML branch, where the wrapper now also avoids the `undefined` 3rd arg. The wrapper dispatches to the fastest call shape for every input — `{HTML, non-HTML}` × `{with is, without is}` × no `undefined` ever. ## Affects Every place Svelte constructs a DOM element internally: ``, `run_scripts`, the per-component `