title: Horrible performance when removing HTML element from UIWebView
body: <p>I'm currently writing an iOS app that uses a UIWebView for surfing around pages. Sometimes I need to dynamically remove elements in the UIWebView using <code>stringByEvaluatingJavaScriptFromString:</code>, but this locks up the main UI for sometimes up to 2 seconds on my first gen iPod touch, and maybe half a second on an iPhone 3GS. The JavaScript I'm using to remove it by is simply:</p>
  
  <pre><code>element.parentNode.removeChild(element);
  </code></pre>
  
  <p>Nothing more complicated than that. At the same time I'm doing some very basic 2D rendering in OpenGL ES, and if rerendering the UIWebView wouldn't lock up I would use just simple CoreAnimation on the main thread. Could it be that it has to recalculate the DOM tree, all element positions etc? Should this really lock up the main UI thread? Is it that I'm calling <code>stringByEvaluatingJavaScriptFromString:</code> that locks up everything? Is this normal and to be expected on this kind of hardware? The odd thing is it is able to render some semi-complex MooTools animations in the webview, with opacity and height changes, but removing one single element takes several seconds. </p>
  
  <p>Does anyone have any ideas in improvements? Maybe just hiding elements using <code>visibility: hidden</code> is better, or setting <code>opacity: 0</code>?  Any thoughs or wise words of experience?</p>