The maximum data limit can be set using the jQuery html () method

I modify the contents of a div through the jQuery .html() method when I get the response text from an Ajax event.

Sometimes I get more response data (contains html and script and about 4 MB of data). It takes more time to set the response data as the contents of a div using the jQuery .html() method.

Can someone tell me the reason? Is there any solution or alternatives?

+4
source share
1 answer

Firstly, regular loading and pasting of 4 MB HTML is NEVER going to make a quick interactive application. It will be a network pig and a swamp of memory and will not work well.

There is no technical limit for the .html() method, besides how much memory the browser can get. .html() is a wrapper on top of the native .innerHTML , which has no particular restrictions.

4 MB of HTML takes considerable time to load and considerable time to parse the browser. This is probably a delay. Time is probably not related to jQuery. After a small initial housekeeping that has nothing to do with the actual content that you install, jQuery simply sets the .innerHTML property, and the browser handles the parsing of the HTML content that you gave it.

Now, if you are replacing a large amount of HTML (for example, another 4MB HTML set), then jQuery can be much slower because it must traverse every element of the old content and make sure that it clears any jQuery state associated with those elements to be deleted.


You really need to fix the page design / application design so that you don't have to use 4 MB of HTML.

+3
source

All Articles