Side navigation
#7898 closed enhancement (invalid)
Opened January 04, 2011 10:13PM UTC
Closed January 08, 2011 03:28AM UTC
Last modified December 06, 2011 02:20PM UTC
replaceWith() terribly slow in IE8
Reported by: | info@javinto.nl | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | |
Component: | manipulation | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When using $('elm').replaceWith(string) where elm has multiple nested children (need not be a lot) it took IE8 10 seconds to perform its task.
After having modified the replaceWith() method in the jQuery source:
- jQuery( this ).remove();
+ jQuery( this ).empty().remove();
It took IE8 less than a second to complete its task, like in Firefox 3.6
Attachments (0)
Change History (3)
Changed January 08, 2011 03:28AM UTC by comment:1
component: | unfiled → manipulation |
---|---|
milestone: | 1.6 |
resolution: | → invalid |
status: | new → closed |
Changed January 10, 2011 10:12AM UTC by comment:2
Thanks for your quick and appopriate response! Good suggestion.
Changed December 06, 2011 02:20PM UTC by comment:3
I am also having problems with <code>relpaceWith</code> performance; but in my case <code>.emtpy()</code> doesn't help.
I am using DOM API, <code>replaceChild</code>, it works about 5 times faster.
I test this by replacing HTML table; IE8; jquery 1.6.1.
Crossposting this info here from the discussion at https://issues.apache.org/jira/browse/WICKET-4236.
Thanks for taking the time to contribute to the jQuery project by writing a bug report. The reason for this is that
replaceWith()
returns the removed element. The documentation saysIf you don't need this "return" value you can just yourself call
$('elem').empty().replaceWith(string)
instead of modifying the jQuery source which is a very bad idea (consider the hassle when upgrading to another jQuery version, breaking replaceWith for e.g. plugins relying on the specified behavior)I made a "hacked up" test case which shows how incorporating your "fix" breaks the behavior of replaceWith().