Why does the following jQuery code cause my browser to hang?
Caution: do not run this unless you are prepared to force quit your browser
<!DOCTYPE HTML>
<title>Simple clone</title>
<script type="text/javascript" src="jquery.js"></script>
<div>
<script>$('div').clone().appendTo('body');</script>
</div>
Edit
For those in the "infinite loop" camp, that should not be an issue. A perfectly safe (non-jQuery) version is:
<div>div
<script>
var el = document.getElementsByTagName('div')[0];
document.body.appendChild(el.cloneNode(true));
</script>
</div>
So the issue is specifically related to how jQuery does clones.
Edit 2
It seems that jQuery causes script elements in clones to be executed. That isn't standard behaviour and is something about how jQuery does clones that is quite unexpected.