title: Best way to create dynamic content using javascript?
body: <p>Does it matter if I create the element and set the element attributes programmatically as in snippet 1 verses writing out the innerHTML as in snippet 2? What about using a templating library as suggested in one of the answers?</p>
  
  <p><strong>snippet 1</strong></p>
  
  <pre><code>var link_element,
      image_element;
  
  // create image element
  
  image_element = $A.createElement('img');
  image_element.className = "bookmark_image";
  image_element.name = "bo_im";
  image_element.src = bookmark_object.favicon;
  
  // create link element
  
  link_element = $A.createElement('a');
  link_element.innerHTML = bookmark_object.title;
  link_element.href = bookmark_object.url;
  link_element.name = "bookmark_link";
  link_element.className = "bookmark_link";
  link_element.target = "_blank";
  
  // append now
  </code></pre>
  
  <p><strong>snippet 2</strong></p>
  
  <pre><code>'&lt;img name="bo_im class="bookmark_image" src="' + val.favicon + '"&gt;' +
  '&lt;a target="_blank" name="bookmark_link" class="bookmark_link" href = "' + val.url + '" id="' + val.id + '"&gt;' + val.title + '&lt;/a&gt;' +
  
  // set to innerHTML now
  </code></pre>