Suppose we have a complex template string (possibly a div containing many other tags ..), and we need to add this HTML node several times to our existing document.
Will it be faster to create HTML nodes from the template each time
var $html = $(template); // 1st run var $html = $(template); // 2st run ...
or create them only once, and then clone them:
var $template = $(template); // init var $html = $template.clone() // 1st run var $html = $template.clone() // 2st run ...
jquery templates
lrsjng
source share