title: Questions about performance jQuery
body: <p>I had a question about performance ?</p>
  
  <p>Is it better to have the two images written in html, one hidden and one displayed, and with jQuery change the display of both (to hide the one displayed, and show the hided one) ?</p>
  
  <pre><code>&lt;img id="1" style="display:none;" src="img1.png" /&gt;
  &lt;img id="2" src="img2.png" /&gt;
  $('#1').onclick(function (){
    $(this).css('display', 'none');
    $("#2").css('display', 'inline-block');
  });
  $('#2').onclick(function (){
    $(this).css('display', 'none');
    $("#1").css('display', 'inline-block');
  });
  </code></pre>
  
  <p>or is it better to change the src of the image ?</p>
  
  <pre><code>$('#1').onclick(function (){
    if ($(this).attr('src') == 'img1.png')
      $(this).attr('src', 'img2.png');
    else
      $(this).attr('src', 'img1.png');
  });
  </code></pre>
  
  <p>Thank you very much!</p>