Hacker News new | past | comments | ask | show | jobs | submit login

I imagine it makes the API easier for non-JS developers. Considering its origins as a purely client-side library it does makes sense, as there would be no need to worry about moving script tags down the page to speed up execution.

Technically, you could probably replace the document.write with something like:

   var scripts = document.getElementsByTagName('script');
   var current = scripts[scripts.length - 1];
   var temp = document.createElementNode('div');
   temp.innerHTML = this.generateHTML();
   current.parentNode.insertBefore(temp, current);
I wrote a script that hijacks document.write calls a little while back (https://github.com/joshduck/Injector.js) which lets you inject arbitrary HTML into your document and then execute inline scripts (including document.write) at a later time.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: