Frontend Masters Boost RSS Feed https://frontendmasters.com/blog Helping Your Journey to Senior Developer Wed, 31 Dec 2025 23:03:30 +0000 en-US hourly 1 https://wordpress.org/?v=6.9 225069128 Preserve State While Moving Elements in the DOM https://frontendmasters.com/blog/preserve-state-while-moving-elements-in-the-dom/ https://frontendmasters.com/blog/preserve-state-while-moving-elements-in-the-dom/#respond Wed, 31 Dec 2025 23:03:28 +0000 https://frontendmasters.com/blog/?p=8131 Bramus wrote this almost a year ago, but I’d still call it a relatively new feature of JavaScript and one very worth knowing about.

With Node.prototype.moveBefore you can move elements around a DOM tree, without resetting the element’s state.

You don’t need it to maintain event listeners, but, as Bramus notes, it’ll keep an iframe loaded, animations running, dialogs open, etc.

]]>
https://frontendmasters.com/blog/preserve-state-while-moving-elements-in-the-dom/feed/ 0 8131