← Chrome 157 reference

v157 · web api · sanitizer · enabled by default

Add javascriptURLs option to SanitizerConfig and Sanitizer

Limited availability

  • Chrome · 157 (this option; the host Sanitizer API shipped in 146)
  • Edge · mirrors Chrome
  • Firefox · Shipped/Shipping (ChromeStatus vendor view; host API since 148)
  • Safari · not shipped (position “Support” for the host API)

Not a Baseline feature: the host Sanitizer API web-feature on webstatus.dev is itself Baseline limited (Chrome 146, Firefox 148, no Safari; queried 2026-11-01), and BCD’s setJavascriptURLs subfeature records no shipped version yet (version_added: false, marked experimental; freshness gap vs the milestone-157 listing, disclosed here).

A new boolean knob in the HTML standard’s Sanitizer API that makes javascript:-URL removal a developer-selectable option instead of a side effect of which method you call: SanitizerConfig gains a javascriptURLs member and Sanitizer gains a setJavascriptURLs(allow) method. Previously the API stripped javascript: URLs only via the “safe” methods (setHTML(), parseHTML()); with the option, the “unsafe” methods can remove them too — and a custom config can state the choice explicitly. MDN’s SanitizerConfig and Sanitizer pages do not document this option yet (checked 2026-11-01), so this reference covers it.

at a glance

What it isA boolean javascriptURLs member on SanitizerConfig plus Sanitizer.setJavascriptURLs(allow): “Sets whether the sanitizer preserves attributes containing javascript: URLs” (spec prose, quoted verbatim)
Whyjavascript:-URL stripping used to be hard-wired to the “safe” methods only — “awkward if users wanted to use the ‘unsafe’ methods for some reason, but still wanted javascript:-URLs removed” (ChromeStatus motivation; discussion in whatwg/html #12686, normalized by PR #12898)
Milestone listingChrome 157 — listed under “Enabled by default” in the milestone=157 listing (fetched 2026-11-01; the listing is authoritative for filing); desktop milestone 157 on the API record
Runtime featureNo dedicated flag record: runtime_enabled_features.json5 has no SanitizerJavascriptURLs entry (verified 2026-11-01; that name is the record’s Finch rollout name). The umbrella SanitizerAPI feature is status: "stable"
SpecHTML Standard — setJavascriptURLs() (merged into the living standard; the ChromeStatus record’s spec link is the spec PR)
ChromeStatus5169798320357376 — Add javascriptURLs option to SanitizerConfig and Sanitizer
Intent to Shipblink-dev intent thread (linked from the ChromeStatus record)
Source: HTML Standard, Sanitizer interface; ChromeStatus API record — fetched 2026-11-01

why it exists

The Sanitizer API has two families of insertion methods: the safe ones (Element.setHTML(), Document.parseHTML()), which guarantee no script can survive sanitization, and the unsafe ones (setHTMLUnsafe(), parseHTMLUnsafe()), which apply only the configuration you give them. javascript: URLs in navigating attributes (an <a href>, a <form action>, …) are a script vector, so the safe methods always stripped them — but that behavior was attached to the method, not the configuration. whatwg/html issue #12686 called this out, and PR #12898 regularized it into the explicit javascriptURLs configuration option, so an unsafe-method caller can still opt in to javascript:-URL removal, and any configuration can state its choice explicitly.

Source: whatwg/html #12686; whatwg/html PR #12898; ChromeStatus motivation

syntax

From the HTML living standard (IDL quoted verbatim, fetched 2026-11-01; Sanitizer is [Exposed=Window]):

dictionary SanitizerConfig {
  // … elements, removeElements, replaceWithChildrenElements,
  //     attributes, removeAttributes …
  boolean comments;
  boolean dataAttributes;
  boolean javascriptURLs;      // NEW in this change
};

[Exposed=Window]
interface Sanitizer {
  constructor(optional (SanitizerConfig or SanitizerPresets) configuration = "default");
  SanitizerConfig get();
  // … allowElement, removeElement, replaceElementWithChildren,
  //     allowAttribute, removeAttribute, setComments, setDataAttributes …
  boolean setJavascriptURLs(boolean allow);   // NEW in this change
  boolean removeUnsafe();
};
Source: HTML Standard — the Sanitizer interface (elided members marked with ellipses; the two new items verbatim)

the javascriptURLs member — inputs and defaults

A plain Web IDL boolean. true means the sanitizer preserves attributes containing javascript: URLs; false means it removes them. When the member is absent, the default depends on how the configuration is used: the spec’s built-in safe default configuration carries javascriptURLs: false (remove), while canonicalization of a custom configuration fills an absent member from the permissive defaults (“If configuration["javascriptURLs"] does not exist, then set it to permissiveDefaults” — spec step, quoted) — so an unsafe-method call with a config that doesn’t mention the member keeps javascript: URLs, exactly as before this change. There is no third state.

Source: HTML Standard — SanitizerConfig (member, safe default table, canonicalization steps)

the setJavascriptURLs(allow) method

Quoting the method steps verbatim: “Let configuration be this’s configuration. Assert: configuration is valid. If configuration["javascriptURLs"] is allow, then return false. Set configuration["javascriptURLs"] to allow. Return true.” So the boolean return value reports whether the configuration changed — false means the sanitizer was already in the requested state. The method throws no exceptions; the only input is the required allow boolean (any JS value coerces per Web IDL boolean conversion).

Source: HTML Standard — setJavascriptURLs() method steps

what it changes during sanitization

Source: HTML Standard — sanitization algorithms (quoted steps; fetched 2026-11-01)

where it applies

Sanitizer is [Exposed=Window]; the option takes effect wherever a SanitizerConfig or Sanitizer is consumed: Element.setHTML() / setHTMLUnsafe(), ShadowRoot.setHTML() / setHTMLUnsafe(), and Document.parseHTML() / parseHTMLUnsafe(). No permission, secure-context restriction, or flag is recorded for it; in Chrome it ships with the stable SanitizerAPI runtime feature (milestone 157 for this option per the listing). Feature-detect the method directly:

const supported = "setJavascriptURLs" in Sanitizer.prototype;
Source: HTML Standard — Sanitizer interface; runtime_enabled_features.json5

examples

// Unsafe method, but with javascript: URLs removed — the case
// that motivated the option (previously impossible):
const sanitizer = new Sanitizer();        // "default" preset
sanitizer.setJavascriptURLs(false);       // returns true if it changed
el.setHTMLUnsafe(userMarkup, { sanitizer });

// Same thing as a plain config dictionary:
el.setHTMLUnsafe(userMarkup, {
  sanitizer: { javascriptURLs: false },
});

// The setter's return value reports change, not success:
const s = new Sanitizer({ javascriptURLs: false });
s.setJavascriptURLs(false);               // → false (already in that state)
s.setJavascriptURLs(true);                // → true  (configuration changed)

// Inspect the resulting configuration:
console.log(s.get().javascriptURLs);      // → true
Live example from the Chrome Platform Showcase (route HEAD-checked 200, 2026-11-01). Sibling concept demos: config inspector, escape artists, and untrusted comment feed. Requires Chrome 157+.Source: chrome-platform-showcase
Source: call forms per the HTML Standard IDL and the quoted method steps; examples are gendn-authored and labelled as such

browser compatibility

Per-version data from BCD api/Sanitizer.json (fetched 2026-11-01). BCD already has a setJavascriptURLs subfeature key, but no browser has a recorded version yet — a freshness gap against the Chrome milestone-157 listing, shown as such.

BrowserSanitizer (host API)setJavascriptURLs / javascriptURLs
Chrome146 (webstatus.dev)Milestone 157 per the ChromeStatus record; BCD version_added: false (not yet recorded)
Edge146 (mirrors Chrome)Mirrors Chrome
Firefox148 (webstatus.dev)“Shipped/Shipping” per the ChromeStatus vendor view; BCD version_added: false (not yet recorded)
SafariNot shipped; position “Support” for the host API (WebKit/standards-positions #86)Not shipped

For orientation, the host Sanitizer API web-feature is Baseline limited on webstatus.dev (Chrome 146 · Firefox 148 · no Safari).

Source: BCD api/Sanitizer.json; webstatus.dev sanitizer; ChromeStatus API record

security and privacy

Source: HTML Standard sanitization algorithms; whatwg/html PR #12898; the migration note is gendn-derived from the quoted defaults, labelled as such

specifications

DocumentStatus
HTML Standard — Sanitizer.setJavascriptURLs() and the SanitizerConfig dictionaryLiving standard — the option is merged text (verified present 2026-11-01)
whatwg/html PR #12898 — the change that added the optionThe ChromeStatus record’s spec link; merged into the living standard
whatwg/html issue #12686 — originating discussionMotivating issue, linked from the ChromeStatus motivation
Repository and thread records are linked above; contents fetched 2026-11-01.

see also