title: Why is this javascript function so slow on Firefox?
body: <p>This function was adapted from the website: <a href="http://eriwen.com/javascript/measure-ems-for-layout/" rel="nofollow">http://eriwen.com/javascript/measure-ems-for-layout/</a></p>
  
  <pre><code>function getEmSize(el) {
      var tempDiv = document.createElement("div");
      tempDiv.style.height = "1em";
      el.appendChild(tempDiv);
      var emSize = tempDiv.offsetHeight;
      el.removeChild(tempDiv);
      return emSize;
  }
  </code></pre>
  
  <p>I am running this function as part of another function on window.resize, and it is causing performance problems on Firefox 3.6 that do not exist on current Safari or Chrome. Firefox's profiler says I'm spending the most time in this function and I'm curious as to why that is. </p>
  
  <p>Is there a way to get the em size in javascript without doing all this work? I would like to recalculate the size on resize incase the user has changed it.</p>