Editing Combine DOM nodes This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Compare performance of jQuery vs. native DOM APIs in moving the contents of one element under another. Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) $("body").append('<span id="test">Lorem ipsum <span id="selected-1">dolor sit</span><span id="selected-2" title="important info here"> amet, consectetur</span> adipiscing elit.</span>'); Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) $("#test").remove(); Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code var span1 = document.getElementById("selected-1"), span2 = document.getElementById("selected-2"), insert = span2.firstChild, elt; while (elt = span1.lastChild) { insert = span2.insertBefore(elt, insert); // removes the node from span1 } // This line causes jsperf to fail--why? // span1.parentNode.removeChild(span1); Test 2 Title Async (check if this is an asynchronous test) Code $('#selected-2').prepend($('#selected-1').html()).prev().remove();