Is there a limit on the size of the string passed to jQuery.append ()

I wrote a basic program in Angular that uses router functionality to expose two pages as a single page application. So far, that's all he does. I have a page that contains two buttons for navigation and a wrapping div (ng-view) that fills with the contents of the two pages when the corresponding button is clicked.

When I try to load the larger of the two pages, I get the following error:

SyntaxError: Unexpected token <

This error is picked from angular.js: 11594 (I'm using version 1.3.9). After debugging, I found that an exception was thrown in jQuery, from the code:

this.empty().append( value );

I looked at the input parameter 'value' and it is very large. It contains over 11,000 lines and is 1.59 MB in size.

I have run the input line in the validation html file ( http://www.freeformatter.com/ ). The format is fine and there is no additional opening tag.

Is it possible the jQuery method cannot handle such a large string? I searched Google for such a limit, but all I could find were suggestions for applying constraints with jQuery, and the documentation ( http://devdocs.io/jquery/append ) doesn't mention such a limit.

Notes:

  • I am using jQuery version 1.11.0
  • I can't update the version because my team is using PrimeFaces and this is the jQuery version that matches the PrimeFaces version.
  • The exception was thrown from line 5830.
  • A large file is generated by JSF on the server side. I cannot change it.
  • I tried using iframes and it works. I am assuming only the iframe element is added with jQuery and then large content is loaded into the iframe. My supervisor doesn't want me to use iframes, so it doesn't help.

Thank.

+3


source to share


1 answer


The first limitation you will run into is that if the string is more than 512 bytes, then the dom fragments it creates are not cached. The next limit is the .innerHTML limit in the browser. But it is quite large (tall) ... But when adding a lot of content, you will encounter huge delays (it can take a very long time to load).



-1


source







All Articles