The more I think about this, the more I like it. I'd really love to be able to write code like this on the server side:
var document=new DOMDocument("template.html");
document.body.onload=function() {
alert("test");
};
document.sendToClient();
Building DOM documents on the server, and then dumping them to HTML for the client to rebuild would be great, especially if function references and closures would be preserved.