Shorter DOMscript via cloning vs. generating elements
Thursday, December 8th, 2005
I just looked through some of my older scripts and other people’s code and realised that a lot of time we bloat our methods by repeating the same functionality.
This is especially true when it comes to generating a lot of HTML via the DOM.
We keep repeating the same document.createElement and setAttribute lines over and over. Wouldn’t it be more efficient to create those once when initialising our script and then cloning them? (more…)