# Remote function: poor performance when erasing a div with lots of elements

**URL:** <https://www.ruby-forum.com/t/remote-function-poor-performance-when-erasing-a-div-with-lots-of-elements/172826>\
**Category:** Rails\
**Created:** [July 28, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/remote-function-poor-performance-when-erasing-a-div-with-lots-of-elements/172826 "2009-07-28T17:39:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kghose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c57346/32.png) [@kghose](https://www.ruby-forum.com/u/kghose)\
**Post date:** [July 28, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/remote-function-poor-performance-when-erasing-a-div-with-lots-of-elements/172826/1 "2009-07-28T17:39:09Z")

</div>

Hi,

I have a controller action that just has to replace a div with  
nothing:

# Controller -

def contract  
render :text =\> “”  
end

# -------

I would think that this action would operate at the same speed  
regardless of what was in the div. I find, however, when there is a  
lot of text/material in the div the action takes longer to complete.

Is there a ‘proper’ way to do this that is more efficient?

I’m running Ruby version 1.9.1, Rails version 2.3.2 on a i386-  
darwin9.6.0 platform (mac os X)

best  
-Kaushik

---

<div class="post-metadata">

**Author:** ![kghose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c57346/32.png) [@kghose](https://www.ruby-forum.com/u/kghose)\
**Post date:** [July 28, 2009, 5:53pm UTC](https://www.ruby-forum.com/t/remote-function-poor-performance-when-erasing-a-div-with-lots-of-elements/172826/2 "2009-07-28T17:53:13Z")

</div>

Hi,

A search suggests that this may be a browser bottleneck, rather than a  
rails bottleneck. Rails finishes the task in 1ms, and there is a lag  
until the browser (Firefox) updates the div. And according to this  
link  
[javascript - Why is innerHTML = "" slow in Firefox - Stack Overflow](http://stackoverflow.com/questions/609698/why-is-innerhtml-slow-in-firefox),  
this may be a browser issue.

Best  
-Kaushik
