Skip to content

Comment on HP open sources Enyo javascript framework from webOS, now cross platformparent

Comments

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.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.