How efficient is .clone()? <p>I have a page with a canvas area (nothing to do wth HTML5) where people can create "art" by dragging in photos, creating divs that they can drag, stretch, color, etc. etc. etc. The canvas div is inside a canvasContainer div. Now I'd like to implement an UNDO option. My thought was to do a</p> <pre><code> canvasBackup$ = $('#canvas').clone(); </code></pre> <p>when an operation began, say at every dragStart event, and at the end of the operation an UNDO, if asked for with Ctrl-Z, would execute</p> <pre><code> $('#canvas').remove(); canvasBackup$.appendTo($('#canvasContainer'); </code></pre> <p>My concern is that the clone, and perhaps the append, might be a bit compute intensive as the page grows and start slowing down the page's responsiveness. I suppose it depends on how jQuery does the clone. If it just breaks off the section from the DOM and does a straight memory copy, it shouldn't be bad. But if there's a lot of calculation and building going on it could be a problem.</p> <p>Does anyone have a feel for whether this is a reasonable approach to implementing UNDO?</p> <p>Thanks</p>