开发者

Firefox DOMContentLoaded and load events are very slow on large content in textarea

开发者 https://www.devze.com 2023-02-19 22:01 出处:网络
I\'m trying to load up a large (several megs) document in a textarea. Ignoring the network load time (which is actually minimal when I reload it as it\'s getting a 304), in Firebug it\'s telling me t

I'm trying to load up a large (several megs) document in a textarea.

Ignoring the network load time (which is actually minimal when I reload it as it's getting a 304), in Firebug it's telling me that it's taking nearly 20 seconds for the DOMContentLoaded and load events to get around to firing.

If I change the textarea to a div, it drops the time to 5 seconds, even though it has to actually render the entire contents!

There are no javascript l开发者_如何学Cibraries loaded - unloading them was the first thing I tried. I do have a number of CSS files loaded.

Any ideas about what makes it so slow or, even better, how to speed things up? Load the content a chunk at a time? Kind of ugly but at least it gives the user something to look at rather than a locked browser and potential "this script is taking too long" warnings.

This is Firefox 3.6.15 on Ubuntu.


David, in Firefox 3.6 and earlier textareas with very long content are pretty slow because the editor code reformats the DOM inside the textarea: it creates one textnode and one <br> per line. This is a lot more work than just rendering a single textnode child of a <div>.

You should try Firefox 4, which edits the textnode (or rather a clone of it) directly; I suspect it will be much faster on your page.

As far as speeding this up for users... your only real options with old Firefox versions are to not have so much text in a textarea, unfortunately.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号