简体   繁体   中英

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

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 libraries 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM