Search code examples
htmlgoogle-chromesafaripre

Text in pre element not showing when > 65535 characters Chrome, safari


I have a <pre> element I'm filling with a large amount of text (about 72000 characters in this case). In chrome and safari, I notice that the text inside the <pre> is getting divided in two at the 65535 character mark. I can tell this because in the inspector, I can select the two blocks of text similar to how I can select an element.

You'd think that in this case, you would see the first 65535 characters, but instead, I'm actually seeing the second block of characters, while the first 65535 characters are hidden. I think this is because the text inside the element contains escaped XML.

Is there any way around this character limit for the text inside a <pre> element?


Solution

  • Text nodes have maximum memory limit, which in this case seems to be 65535 bytes. Therefore when you have text larger than that - it will be placed in two text nodes.

    Not sure what do you mean by "while the first 65535 characters are hidden", I tried it here: http://jsfiddle.net/valentinas/dv99r/1/ and it looks fine on Chrome 23.