News for hackers. Stuff that matters.
Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by aneth on Thursday April 26, 2012 @12:15AM (#3892373)
This is pretty, but unfortunately the only performant way to generate dom elements in javascript is with HTML. HTML parsing is orders of magnitude faster in most browsers.

How about a library like this to generate a string of HTML instead of dom elements?

Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by Stratoscope on Thursday April 26, 2012 @12:38AM (#3892455)
I tried that some years ago (see my other comment). I had a very similar DOM creation function and I updated it to generate HTML instead. It was almost as slow as before - and then I realized that the sheer amount of JS code I was running to generate the HTML was taking up the time.

Of course the performance tradeoff would be different in modern browsers.

Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by joestelmach on Thursday April 26, 2012 @12:21AM (#3892396)
While I don't entirely agree with your first statement, you could just grab the outerHTML instead of appending the element directly to the DOM:

  $.el.div($.el.span()).outerHTML
Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by aneth on Thursday April 26, 2012 @12:24AM (#3892415)
Seems like a reasonable solution.

My first statement was certainly true in the previous generation of browsers, including IE 7. I'm not sure about more modern browsers. What basis do you have for disagreeing?

Refer to:

http://www.quirksmode.org/dom/innerhtml.html

Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by joestelmach on Thursday April 26, 2012 @12:35AM (#3892451)
I'm only disagreeing with the use of the word 'performant', and the popular viewpoint that any solution that isn't as fast as possible can't be labeled as such.
Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by betageek on Thursday April 26, 2012 @03:44AM (#3892898)
I started one in 2009 (https://github.com/dburrows/markup-builder) inspired by Ruby's Builder library but abandoned it - it was only really useful for small amounts of code and for any sizeable project it's far better to use templates
Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by mistercow on Thursday April 26, 2012 @12:17AM (#3892380)
Seems to me like an implementation detail that shouldn't have to affect the interface at all.
Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by firefoxman1 on Thursday April 26, 2012 @12:19AM (#3892389)
Like a template engine?
Re:Laconic: A Sane Method of Generating DOM Content in JavaS... by aneth on Thursday April 26, 2012 @12:21AM (#3892397)
Perhaps like some template engine, but not like any I know of.