|
|
|
|
|
by Stratoscope
5174 days ago
|
|
Just for fun, here's my version from 2006: http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-pro... It's based on Bob Ippolito's version from 2005. :-) The comments on the post have a few other interesting implementations that others contributed. At the time I got pretty excited about this idea, but I abandoned it after a while for performance reasons. I was building large DOM structures and it was really slow. I knew that innerHTML was faster, so I tried keeping the same syntax and generating HTML from it instead of DOM insertions - and it was almost as slow that way! Then I realized that it was just the sheer amount of JavaScript code being run that was slowing it down. I changed my code to build HTML strings with array pushes and a join at the end and then innerHTML to insert, and it was much faster. Of course, JavaScript has gotten a lot faster since then (at least in new browsers!), so the more code-intensive techniques may be more practical now. |
|
JavaScript has come a long way, even from 2006, yet most developers still have the mindset that this sort of thing can't perform well. What we're left with are solutions that are more complex, and perform similarly for most applications.