title: MutationObserver is slow and adds too much to the DOM
body: <p>I'm not sure what the best way to describe this is, but I'm calling the mutation observer every time the DOM changes and for some reason it keeps adding DOM to my page instead of overwriting DOM that it has already created. </p>
  
  <p>To be more specific, I'm building a chrome extension that every time a user hovers their mouse over a specific word they get a <code>div</code> popup. This works perfectly fine without the <code>mutationobserver</code> but when I do add the <code>mutationobserver</code> it seems to add a lot of the popups every time the user hovers. This is obviously really bad...</p>
  
  <p>Here is my code that I use to add the hover <code>(codeSegment1)</code>:</p>
  
  <pre><code>jQuery(document).ready(function($) {
  
      $('.newHover').each(function() {    
  
          Tipped.create(this, "&lt;iframe src='http://myurl.com"'&gt;&lt;/iframe&gt;", {
              skin: "white",
              position: 'right',
              background: '#fff',
              detach: false,
              shadow: true,
          }); 
  
      });
  
  });
  </code></pre>
  
  <p>As I said this works fine the first time...</p>
  
  <p>Here is my code for the mutation observer <code>(codeSegment2)</code>:</p>
  
  <pre><code>var arrayOfP = $("p").text();
  var observer = new WebKitMutationObserver(function(mutations) {
      //Sends message to another document and the other document 
      //sends a message back to the code above (i.e Tipped.create)                
      chrome.runtime.sendMessage(arrayOfP, manageResponse); 
  });
  observer.observe(document.body, { 
      attributes: true, 
      childList: true, 
      characterData: true 
  });
  </code></pre>
  
  <p>So here is what I think is happening:</p>
  
  <ul>
  <li>Page loads.</li>
  <li><code>codeSegment1</code> does it's thing.</li>
  <li>New text is dynamically added to page</li>
  <li><code>codeSegment2</code> fires</li>
  <li><code>codeSegment1</code> does it's thing again, and again, and again. </li>
  </ul>
  
  <p>I could be wrong. But I was hoping someone on here could shed some light on what's happening and how I can fix it.</p>
  
  <p>Thanks.</p>