Back to all features
Open for signals DOM

moveBefore()

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.

Modern Web Guidance

How Modern Web Guidance uses this feature

Repositions DOM nodes across parent containers using Node.prototype.moveBefore() while preserving internal element state (such as iframes, video playback, and active focus).

Recommended fallback strategy

For browsers without Node.prototype.moveBefore(), fall back to standard element.insertBefore() or element.appendChild(). Note that DOM state (such as iframe reloads, video playback, and active focus) will reset during the fallback operation.

Community use cases (0)

No use cases submitted yet

Be the first developer to describe your production use case and shape browser priorities!