coderef

moveBefore()Limited availability

The moveBefore() DOM method relocates a node while preserving its state. For example, you can move the active element without losing focus, move an animated element without resetting the animation, or move an iframe without reloading its content.

Not yet supported in all major browsers — check the table and provide a fallback.

Browser support

DesktopChrome
1–132Not supported
133+Supportedsince Feb 4, 2025
Current: 155
Edge
12–132Not supported
133+Supportedsince Feb 6, 2025
Current: 154
Firefox
1–143Not supported
144+Supportedsince Oct 14, 2025
Current: 157
Safari
✕Not supportedup to 27
Current: 27
MobileChrome Android
18–132Not supported
133+Supportedsince Feb 4, 2025
Current: 155
Firefox Android
4–143Not supported
144+Supportedsince Oct 14, 2025
Current: 157
Safari iOS
✕Not supportedup to 27
Current: 27

How to use

Not supported in Safari, Safari iOS. Use feature detection below and provide a fallback (or a polyfill) for those browsers.

Example

Full syntax and examples are on MDN: moveBefore.

Feature detection

JS · check before using
if ("Document" in globalThis && "moveBefore" in Document.prototype) {
  // Document.moveBefore is available
}

Sub-features

Support for each part of the feature (4). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
CustomElementRegistry.define.connectedMoveCallback_lifecycle_callback133133144✕133144✕
Document.moveBefore133133144✕133144✕
DocumentFragment.moveBefore133133144✕133144✕
Element.moveBefore133133144✕133144✕